I need to extract VALUE1, VALUE2 and VALUE3 from the following multi-line string:
String input = "aa a\r\na aa \r\na getString(\"VALUE1\");aagetInt(\"VALUE2\");aa\r\n a getString(\"VALUE3\"); aaa\r\naaa";
I've tried:
Pattern pattern = Pattern.compile("\"(\\S+)\"+");
Matcher matcher = pattern.matcher(input);
while (matcher.find())
System.out.println(matcher.group(1));
But this produces:
VALUE1\");aagetInt(\"VALUE2\");aa\r\n a getString(\"VALUE3
It takes everything between the first and last quotation marks.
Then I've tried this one:
"(.*)get(\\S+)\\(\"(\\S+)\"(.*)"
But this only takes the last match, VALUE3 (with matcher.group(3)).
How can I get all 3 values: VALUE1, VALUE2, VALUE3?