Skip to content

Instantly share code, notes, and snippets.

@RomanVlasenko
Last active December 31, 2015 14:59
Show Gist options
  • Save RomanVlasenko/8003579 to your computer and use it in GitHub Desktop.
Save RomanVlasenko/8003579 to your computer and use it in GitHub Desktop.
Java: string matcher example
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class M {
public static void main(String[] args) {
String url = "http://localhost/blog/booking/?record_locator=FN0RGA";
Pattern p = Pattern.compile("record_locator=((\\d|\\w){6})");
Matcher matcher = p.matcher(url);
if (matcher.find()) {
System.out.println(matcher.group(1));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment