Grouping Regular Expression BackReferences
I have the following RegEx
id=(.*?) | id="(.*?)"
The reason for this is because I am trying to replace IDs from the DOM of browsers with JavaScript. IE however rolls strings from element attributes since it doesn't require them in the DOM
The problem is that the backrefererences from each alternate operator are in separate groups ($ 1 and $ 2), since the match is only one OR the other can return as a backreference as one backlink?
EDIT:
<div id="test1" /><div id=test2 />
will match as follows
match | $1 | $2
--------------------------------
id="test1" | test1 |
id=test2 | | test2
I just want both backlinks to be appended to $ 1
0
source to share
3 answers