I'm attempting to get attributes from a HTML string that will form an array of {key: '...', value: '...'}
via regex. I'm close but I have come across the issue of values containing =
splitting the value.
Here's my current regex:
/(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|[>"']))+.)["']?/g
Here's the test string:
url="https://www.youtube.com/watch?v=123456"
And here's the result: https://regex101.com/r/H2kqVp/1
As you can see, it's splitting after the =
in the value, which it should ideally escape. Any idea how to get around that?
Edit: I'm utilizing gulp-html-partial which uses the regex above. I was hoping there was a simple way to modify the pattern to solve this issue.