I have the following regex:
(?<t>[^:=]*)(:(?<u>[^:=]*))?(:(?<v>[^:=]*))?=(?<value>.*)
Its purpose is to take input like AppSettings:Envionment:Other=Dev and parse it out. And it works great for that.
I now need to change it to parse out AppSettings__Envionment__Other=Dev. Replacing the single colon with a double underscore.
The problem with that is that the ^ operator works on one char only.
In searching, I have found that when you need to match on several chars at a time you should use the negative lookahead feature (?!\_\_). I tried that out (temporarily taking out the need for an equal sign):
(?<t>(?!\_\_)*)(\_\_(?<u>(?!\_\_)*))?(\_\_(?<v>(?!\_\_)))
An input of AppSettings__Envionment__Other it did not get the captures right (t, u and v should be the words between the underscores).
Additionally, I still need it to not match on both the double underscore (__) and the equals (=). Running full ahead of what I would thing should work (but does not) I tried this:
(?<t>(?!\_\_)(?!=)*)(\_\_(?<u>(?!\_\_)(?!=)*))?(\_\_(?<v>(?!\_\_)(?!=)*))?=(?<value>.*)
But that does not even come close to working. (It only matches on the equal sign.)
How can I go from not matching on : and = to not matching on __ and =?
And how would you make a statement that uses ^ for several chars equivalent to several negative lookaheads?
UPDATE:
I should have provided more examples of the inputs that I expect to parse. All of the following need to be parsed by the RegEx:
AppSettings__Envionment__Other=Dev
AppSettings__ConnectionString=SomeValue
LogLevel=Debug