Reputation: 9830
I've the following regular expressions to match:
<string attribute=b>x</string> is matched by : (?<range3>[\w\d\-\:]+)[ ]*=[ ]*[\w\d\-\:]+
<string attribute='b'>x</string> is matched by (?<range1>[\w\d\-\:]+)[ ]*=[ ]*'[^']*'
<string attribute="b">x</string> is matched by (?<range2>[\w\d\-\:]+)[ ]*=[ ]*"[^"]*"
This works fine, however the following is also matched:
<string>attribute=b</string>
<string>attribute='b'</string>
<string>attribute="b"</string>
What regular expression do I need to use to only match the first three examples?
Upvotes: 0
Views: 1687
Reputation: 67968
(?=\S+?>\w+<\S+?)(?<range3>[\w\d\-\:]+)[ ]*=[ ]*[\w\d\-\:]+
Added a positive lookahead to check for >x<.Works now.
Upvotes: 1