Hi, im trying to mask all html "a" tags in php using preg_replace_callback what contains a valid email address in href attribute, "mailto:" would be optional. a-tags can have any possible syntax, so im trying to match all [ \t\r\n\v] and chars between <a........href and after @dd.ee".........>, i assume i have to use (.*?) there, because there might be really everything (large block of php code for example in somebodys ugly template file)... would be nice to match both ' and " around href attribute. case sensitivity^^
i have an issue with range, when i try to find "X" or (.*?) in href, the result is correct, but when i replace X with email-validation, it breaks outside a-tags
here is my ugly syntac ^^ :$
((<a[ \t\r\n\v]+)(.*?)([ \t\r\n\v])*(\bhref\b){1}(=){1})+?((["](mailto:)?(X)["])|(['](mailto:)?(X)[']))((\>)(.*?)(\<\/a>))+?
here is what X should be in the sentece abow
[a-zA-Z0-9]{1}[a-zA-Z0-9._+-]*[a-zA-Z0-9]{1}@[a-zA-Z0-9]{1}[a-zA-Z0-9.-]*[a-zA-Z0-9]{1}\.[a-zA-Z]{2,4}
and here are some possible texts to what need to be matched
<div><a href='example@reg.ee'>example@reg.ee</a></div>
<div><a href="mailto:example@reg.ee">example@reg.ee</a></div>
<a id="someid" href="mailto:example@reg.ee" class="somerand attributes">
Send mail to example@reg.ee
</a>
<div>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
<a id="someid"
href='mailto:example@reg.ee' class="somerand attributes">
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
click example@reg.ee to send mail
reprehenderit in voluptate velit
</a>
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
</div>
ty in advance^^
Jaan