I try to get all html attributes but getting only one encapsilating others
my pattern is:
(\S+)=((".*")|('.*')|(\S*(?=(\s+))))
Content is:
<a href="html.aspx" target="_blank" />
And only one matche returns:
- href=”html.aspx” target=”_blank”
But I want it to be:
- href=”html.aspx”
- target=”_blank”
Any helps would be appreciated.
It’s because you’re using greedy matching (the default) with
.*"which will keep going until it finds the last". Try this regex:The
.*?"tells the regex to search until the first", not the last one.