Created
December 31, 2010 00:11
-
-
Save ericanderson/760518 to your computer and use it in GitHub Desktop.
For Post: Using pretty URLs with Spring and Annotations (pt2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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