how to get data between quotes in java?

You can use a regular expression to fish out this sort of information.

Pattern p = Pattern.compile("\"([^\"]*)\"");
Matcher m = p.matcher(line);
while (m.find()) {
  System.out.println(m.group(1));
}

This example assumes that the language of the line being parsed doesn’t support escape sequences for double-quotes within string literals, contain strings that span multiple “lines”, or support other delimiters for strings like a single-quote.

Leave a Comment