Created
January 31, 2011 23:31
-
-
Save ericanderson/805063 to your computer and use it in GitHub Desktop.
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