0

such string:

interface Loopback0 description "Loopback Interface for network management" ip address 10.20.30.40 255.255.255.255 no ip proxy-arp

how to print what is between " "?

Loopback Interface for network management

Jerry Jeremiah
  • 9,045
  • 2
  • 23
  • 32
YAV
  • 13
  • 2
  • Are you looking to get a substring containing what is inside the quotes? – Nandostyle Jul 02 '20 at 04:07
  • Possible duplicate: https://stackoverflow.com/questions/1473155/how-to-get-data-between-quotes-in-java https://stackoverflow.com/questions/14574689/extract-a-substring-between-double-quotes-with-regular-expression-in-java https://stackoverflow.com/questions/22789293/how-to-get-the-string-between-double-quotes-in-a-string-in-java https://stackoverflow.com/questions/28484273/java-regular-expression-to-get-characters-between-double-quotes https://stackoverflow.com/questions/43723523/how-to-get-string-from-several-double-quotes-in-a-line – Jerry Jeremiah Jul 02 '20 at 04:08
  • 1
    Does this answer your question? [how to get data between quotes in java?](https://stackoverflow.com/questions/1473155/how-to-get-data-between-quotes-in-java) – xMayank Jul 02 '20 at 04:10
  • Can you give a use case? Do you have one pair of ", or a variable number of "s? – Matthew Kligerman Jul 02 '20 at 04:29

1 Answers1

0

Assuming that the " character occurs only 2 times or if you want the first pair:

# Get the indices of the " characters
ind1 = exampleStr.find('"')
ind2 = exampleStr.find('"', ind1+1)

# Get the substring between the two indices
result = exampleStr[ind1+1:ind2]
  • thanks, also per suggested by system similar topic worked for me: Pattern p = Pattern.compile("\"([^\"]*)\""); Matcher m = p.matcher(inpS); while (m.find()) { System.out.println("\nBetween quotes:"+m.group(1)); } – YAV Jul 02 '20 at 05:19