I need to remove a code of digits, preceeded by an underscore in strings that may or may not be cointained in an HTML tag, that may or may not containt the same substring.
Example: remove _1234 from following strings:
this is my string_1234
<a href="link_1234">this is my html nested string_1234</a>
I just do:
$regex = '#\_(\d+)$#';
$name = preg_replace($regex, '', $name);
but I'm removing also the part inside the HREF, so I would like to generally exclude the any occurency that may happen inside the html tag.
EDIT: 1 thing I can be sure, the eventual HTML tag will always be a link... is there a way to ignore with regex anything inside <a ... >
and </a>
?