Created
January 21, 2012 23:24
-
-
Save parker/1654495 to your computer and use it in GitHub Desktop.
Regular expression challenge
This file contains hidden or 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
Does anyone have a regular expression that would pull out all of the arguments as groups? | |
Example inputs (1 per line): | |
"arg one", "arg two", "arg three" | |
"arg one", arg.two, arg.three | |
"arg one", arg.two, "arg.three" | |
"arg , one", arg.two, "arg.three" | |
"class=\"arg\" one", arg.two, "arg.three" | |
"class=\"arg\" one", "arg , two", "arg.three" | |
"class=\"arg\" one", "arg \" \" two", "arg.three" | |
"arguments: A, B, \"C\", D", "arg \" \" two", "arg.three" | |
The groups for the last input would be an array of length 3. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This uses backtracking and hence generates some extra groups. But works (at least on your inputs).