Manu Manu - 1 year ago 43
Java Question

Reading a set of values from a text file

"TEST3":"GGG ",
"TEST3":"EWE ",

This is a
file I want to read and print only 189456,123456 from the above file.Can anyone help me in doing this.Please find the code for reference.Please post the easiest code.....

Pattern p = Pattern.compile("\"Test\"\\s*:\\s*\"(.*)\"", Pattern.CASE_INSENSITIVE);

while ( (line = bf.readLine()) != null) {

Matcher m = p.matcher(line);

// indicate all matches on the line
while (m.find()) {


Answer Source

As for a Regex solution :


Note the ? , it makes your regex to stop at the first match of ".

With spaces in between :