Me again. RegEx again.
Problem: I need to parse a string which consists out of Key-Value pairs.
Keys are separated from values by a "=". Values can contain a "=", but they must be escaped as "\=".
Example
Key1=Text And escaped\= More stuff\=is here Key2=Value number2
Of course the second key can contain an escaped \=, too. Long story short: Values can be a normal string (any character), except that the equal sign must be escaped.
So far I got (?<=\s|^)([\w ]+)=(\w \\=*)?(?=[ \w=]|[$]) , but it only keeps ordinary Key=value pairs, cutting of at whitespaces.
Edit: Thanks to Richard, who provided a perfectly suitable solution.
Problem: I need to parse a string which consists out of Key-Value pairs.
Keys are separated from values by a "=". Values can contain a "=", but they must be escaped as "\=".
Example
Key1=Text And escaped\= More stuff\=is here Key2=Value number2
Of course the second key can contain an escaped \=, too. Long story short: Values can be a normal string (any character), except that the equal sign must be escaped.
So far I got (?<=\s|^)([\w ]+)=(\w \\=*)?(?=[ \w=]|[$]) , but it only keeps ordinary Key=value pairs, cutting of at whitespaces.
Edit: Thanks to Richard, who provided a perfectly suitable solution.
I will never again mention that Dalek Dave was the poster of the One Millionth Lounge Post, nor that it was complete drivel.