Skip to content

Instantly share code, notes, and snippets.

@ericanderson
Created December 31, 2010 00:11
Show Gist options
  • Save ericanderson/760518 to your computer and use it in GitHub Desktop.
Save ericanderson/760518 to your computer and use it in GitHub Desktop.
For Post: Using pretty URLs with Spring and Annotations (pt2)
public class UrlUtils {
public static String[] breakUri(final String uri, final String expectedUrl) {
Pattern p = Pattern.compile(expectedUrl.replace("*", "(.*?)"));
Matcher m = p.matcher(uri);
if (m.find()) {
String[] ret = new String[m.groupCount()];
for (int i=0; i<ret.length; i++) {
ret[i] = m.group(i+1);
}
return ret;
} else {
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment