keyMatch3 function
keyMatch3 determines whether key1
matches the pattern of key2
(similar to RESTful path)
key2
can contain a *
For example, "/foo/bar" matches "/foo/*", "/resource1" matches "/{resource}"
Implementation
bool keyMatch3(String key1, String key2) {
key2 = key2.replaceAll('/*', '/.*');
var reg = RegExp('\{[^/]+\}');
key2 = key2.replaceAll(reg, '[^/]+');
return regexMatch(key1, '^' + key2 + '\$');
}