With a collection of string as so:
string s1 = " Identifier1 = Value1 ## Comment";
string s2 = " Something = SomeData";
string s3 = " Name = information\\t\\t\\t## More comments!";
string s4 = " Nam2 = information";
I need a regex pattern that will grab all of the information on the line after the equals-sign (=) up to either the end of the line OR the ## comment marker, but NOT capture either of them.
Giving me (respectively):
" Value1 "
" SomeData"
" information\\t\\t\\t"
" information"
I've come up with this so far: (?<=[=]).+(?=(?>##|$))
It kind of works, insofar as it manages to grab all text after the = sign until the end of the string, but it never works when there's a comment marker: ## as it still grabs until the end of the string, instead of stopping at the ##.
...and if I change the pattern to: (?<=[=]).+(?=##))
Then it only works on lines with comment markers (and stops before them as desired).
So what am I doing wrong/missing to get it to end the capture either just before ## OR at EOL? Also, I can't use explicit or implicit capturing groups as these patterns are passed into a parser that turns them into non-capturing groups when it processes them.
I've never used look-ahead/behind patterns until just the past few days and this stuff is breaking my brain...