Quantcast
Channel: CodeProject Latest postings for Regular Expressions
Viewing all articles
Browse latest Browse all 224

[Solved]

$
0
0
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.
I will never again mention that Dalek Dave was the poster of the One Millionth Lounge Post, nor that it was complete drivel.

Viewing all articles
Browse latest Browse all 224

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>