java - Using regular expression (String + number) in Scala -
i using regression expression find patterns such as:
"today user id: 123556 cancelled" "january user id: 236477 renewed" "february user id: 645689 dispute"
basically looking string contains "user id: " + number. using following code, couldn't match anything. please give suggestions?
if (mystring.matches("user id: ([0-9]+)")) { println(a) }
it should be:
if (mystring.matches("^user id: ([0-9]+)$")) {
without slashes in regex string , space after user id:
just tested , worked me follows:
string string = "user id: 12345"; if(string.matches("^user id: ([0-9]+)$")){ system.out.println("matches"); }
there lots of "regex cheatsheets" out there. can find 1 such here: http://www.cheatography.com/davechild/cheat-sheets/regular-expressions/
Comments
Post a Comment