I need to parse and return the tagname and the attributes in our PHP code files:
<ct:tagname attr='attr1' attr='attr2'>
For this purpose the following regular expression has been constructed:
(\<ct:([^\s\>]*)([^\>]*)\>)
This expression works as expected but it breaks when the following code is parsed
<ct:form/input type='attr1' value='$item->field'>
The original regular expression breaks because of the > character in the $item->field. I would need to construct a regular expression that ignores the -> or => but not the single >.
I am open to any suggestions… Thanks for your help in advance.
You could try using negative lookbehind like that:
Matches :
Not sure that it the best suited solution for your case, but that respects the constraints.