I am working on a Node.js project, in this project we are searching a bunch of PHP view files, and replacing some of the attributes. I am trying to get the HTML open tag attribute values, and replace them.
Basically, if this is the tag
<tag attr1="[capture ANYTHING inside single/double qoutes]" attr2='[CAPTURE ANYTHING]'></tag>  
I want to capture anything inside the attribute quotes.
and by [ANYTHING] I mean really anything!
example2: attr="with HTML <br/><b>also been captured</b>"
example3: attr="with line break style \n or \n\r this is still is part of what should been captured and this line too!"
example4: attr="a PHP code <?php echo $ThisPHPcodeisInsideTheQoutes?> should be captured as well!"
example5: title="{{angular?'if inside the attribute': 'it should be acptured as well' }}"
I had wrote the next regex:
/<\w+\s+(:?[\w-]+=(:?"|')(.|[\r\n])*?\2\s*?)>?/g
this regex is catching only the first attribute.
#regex breakdown:
<tag start
\w+a word, mainly tag name this will force avoiding PHP tags<?php
\s+a space or multiple sapces<tag attr
(:?a non capturing group1, I want to get Multiple attributes, but capture only the content!
[\w-]+a word or-for exampleattrorng-attr
=the attribute equal sign
(:?"|')a non capturing group2 open quote or double qoutes
(.|[\r\n])*?-- the actual data I am trying to capture, capture everything.or[\r\n]line break\2- back reference to(:?"|')so well have "[data]" or '[data]'
\s*?- zero or more sapces before the next tag not greedy
)- close of non capturing group1
>?- end of opening tag not greedy
I don't understand why multiple attributes are not being captured Thanks in advance for the help
 
     
    