Why is the result of this code "false"?

String myText = "\"assignee\":\"[а-яА-Яa-z_A-z0-9]+$\""; String myRegex = "\"assignee\":\"[а-яА-Яa-z_A-z0-9]+$\""; Pattern SREQUESTBODY_PATTERN = Pattern.compile(myRegex); SREQUESTBODY_PATTERN.matcher(myText); System.out.println(SREQUESTBODY_PATTERN.matcher(myText).find()); 
  • Try to write more detailed questions. Explain exactly what you see the problem, how to reproduce it, what you want to get as a result, etc. - Nicolas Chabanovsky

1 answer 1

Just in the line myText there is no substring corresponding to the regular expression myRegex . According to it, after the third quote should be letters, numbers or underscores, and there is a square bracket.

  • After the third quote like ":" ??? - HSdevelop
  • @HSdevelop, I mean those quotes that are in the value of a variable, and not in the program text. Those. the first and last are not counted. - sercxjo