Title |
Test
Find
Pattern Title
|
Expression |
(?:\s*)(?<=[-|/])(?<name>\w*)[:|=]("((?<value>.*?)(?<!\\)")|(?<value>[\w]*)) |
Description |
Command line named argument parser which allows quoted values and includes "\"" escape for quotes in a quoted value. Non-quoted values can be letter, space or underscore only. Argument names can be letter, space or underscore only. Argument delimiter can be "-" or "/" and name-value separator can be ":" or "=". All arguments must be named. Spaces are not allowed in |
Matches |
/a:"value" -big="this -test:1\"23 is & $#@ _ your life" -test=th_3 |
Non-Matches |
this does not match |
Author |
Rating:
Not yet rated.
Richard Hauer
|
Source |
|
Your Rating |
|
Title: Tweaked for parameter w/o value
Name: Isaac
Date: 6/12/2014 3:09:26 PM
Comment:
caveat emptor - I'm new enough with regex that mine are just dangerous! I attempted to alter this regex to allow for parameters that do not have a value, i.e. p1 or /p2. the result: (?:\s*)(?<=[-|/])(?<name>\w*)([:|=]("((?<value>.*?)(?<!\\)")|(?<value>[\w]*)))?
Title: C# produces different results
Name: KRiusd
Date: 8/23/2013 4:32:44 AM
Comment:
I_ve tried this:
/switch /path="C:/Program Files" /path2="D:\Program Files" /param="test \"xyz\""
On RegExLib via "Test" everything is fine:
path = C:/Program Files
path2 = D:\Program Files
param = test \"xyz\"
But within a C# program I get:
path = C
path2 = D
param = test
Any ideas what's going wrong?
Title: C# produces different results
Name: KRiusd
Date: 8/22/2013 10:52:26 AM
Comment:
I_ve tried this:
/switch /path="C:/Program Files" /path2="D:\Program Files" /param="test \"xyz\""
On RegExLib via "Test" everything is fine:
path = C:/Program Files
path2 = D:\Program Files
param = test \"xyz\"
But within a C# program I get:
path = C
path2 = D
param = test
Any ideas what's going wrong?