How do I match this pattern multiple times in a string for all of them.
1=aa 2=’bb’ 3=” cc” 4=”dd”
The regex should match all these and give 4 matches as
1) 1=aa
2) 2=’bb’
3) 3=” cc”
4) 4=”dd”
I tried and so far I have this, (?<number>\d=)\s*("|')?\s*(?<value>.*?)(?=\d=)
This matches everything except the #4. It is because there is no \d= for the last one. I know I can make it optional by putting a ? at the end, but then it does not match anything correctly, what am I doing wrong.
The
(?=\d=)part means “followed by\d=“. What you need is(?=\d=|$), which means “followed by\d=or end-of-string”: