Last active
December 18, 2015 05:39
-
-
Save nathggns/5734725 to your computer and use it in GitHub Desktop.
This can be used to parse command line arguments
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
| / | |
| (?: # start parameter | |
| (?: # start key value section | |
| (?<keys> # start key | |
| (?: # start long key | |
| --[^=\s]+ # long key | |
| ) # end long key | |
| | | |
| (?: # start short key | |
| -[^=] # short key | |
| ) # end short key | |
| ) # end key | |
| (?: # start value | |
| [=\s] # key value seperator | |
| (?<values> # start real value | |
| (?: # start simple values (not inside quotes) | |
| \\. # escaped characters | |
| | | |
| [^\s\-"'] # normal characters | |
| )+ # end simple values | |
| | | |
| (?: # start advances values (inside quotes) | |
| (?<start>["']) # start quote | |
| (?: | |
| \\. # escaped characters | |
| | | |
| (?!\<start>) # any character | |
| . # besides end quote | |
| )*? | |
| \k<start> # end quote | |
| ) # end adances | |
| ) | |
| )? # end value | |
| ) # end key val section | |
| | | |
| (?<others> # start keyless parameter section | |
| (?: # start simple section (not inside quotes) | |
| (?: | |
| \\. # escaped characters | |
| | | |
| [^\s\-"'] # normal characters | |
| )+ | |
| ) # end simple section | |
| | | |
| (?: # start advanced values (inside quotes) | |
| (?<startkeyless>["']) # start quote | |
| (?: | |
| \\. # escaped character | |
| | | |
| (?!\<startkeyless>) # anything but | |
| . # end quote | |
| )*? | |
| \k<startkeyless> # end quote | |
| ) # end advanced values | |
| ) # end key less parameter section | |
| ) # end parameter | |
| \s? # parameter seperator | |
| /x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment