Last active
December 31, 2015 14:59
-
-
Save RomanVlasenko/8003579 to your computer and use it in GitHub Desktop.
Java: string matcher example
This file contains hidden or 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
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