Created
April 10, 2016 19:53
-
-
Save varrix/e307a0b24c263b67670d698546615fb5 to your computer and use it in GitHub Desktop.
Simple no-dependency character sequence matching using quotations in Java. Source: http://stackoverflow.com/a/1473198
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
String line = "/cmd \"test\""; | |
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." - https://stackoverflow.com/users/3474/erickson
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: test