Java fix regex in code

BernardaDorney

New Member
I need to print @OPOK, but in the following code:\[code\]String s = "\"MSG1\":\"00\",\"MSG2\":\"@OPOK\",\"MSG3\":\"XXXXXX\"}";Pattern pattern = Pattern.compile(".*\"MSG2\":\"(.+)\".*");Matcher matcher = pattern.matcher(s);if (matcher.find()) { System.out.println(matcher.group(1));} else { System.out.println("Match not found");}\[/code\]I get @OPOK","MSG3":"XXXXXX instead, how do I fix my pattern ?
 
Back
Top