I've been making a parser using Regex in PowerShell, and it works really well so far, except for that issue I'm having.
\s*([a-zA-Z_]+)\s*=(?:\s*"(.*)"|([^;#]*))
I've made this Regex to match, with success, these scenarios:
Name= "Value" ;Comment
Will take everything in between quotes after the =
and disregard the rest
Name=Value ;Comment
Will take everything after the =
up to a ;
or #
as a Value
Now that's great but the problem I'm having is that scenario one is going to match as Value[2] and scenario two is going to match as Value[3]. This makes me check which one contains something for the final value, which I don't find clean, and I'm sure isn't necessary. So here comes the question: How can Value[2] contain the result of those two different groups? (Using an entirely different Regex isn't an issue, I've rewritten this one several times already)