I have some form lines
string strA = "Cmd:param1:'C:\\SomePath\SomeFileName.ext':param2"; string strB = "Cmd:'C:\\SomePath\SomeFileName.ext':param2:param3";
I want to split this line into ':' so that I can extract N parameters. Some parameters may contain file paths, as shown explicitly, and I do not want to divide by ":", which are in parentheses. I can do this with a regular expression, but I am confused about how to get a regular expression to split only if there is no "." On both sides of the colon.
I tried
string regex = @"(?<!'):(?!')"; string regex = @"(?<!'(?=')):";
which will continue only if there is no left and no right (negative rear / forward appearance), but it is still split into a colon contained in 'C: \ SomePath \ SomeFileName. int.
How to change this regex to do what I need?
Thank you for your time.
Note. I found that the following regex works . However, I would like to know if there is a better way to do this?
string regex = @"(?<!.*'.*):|:(?!.*'.*)";
source share