Hi Guys,
Is it me or is this VERY complicated.
Basically I have this string (this is an example there may be other strings with 50 emails in it):
[code=php]$string = ‘see listed on the guide please <a href=”mailto:[email protected]?subject=this is subject”>let us know</a>,
and if you would like to be listed then please <a href=”mailto:[email protected]?subject=Please list me”>contact us</a>.’;
and I want to convert it to:
[code=php]see listed on the guide please <span class=”mailme”>feedback(at)xxxxx(dot)com</span><span class=”mailme_extra”><span class=”subj”>this is subject</span><span class=”tit”>let us know</span></span>,
and if you would like to be listed then please <span class=”mailme”>ads(at)xxxxx(dot)com</span><span class=”mailme_extra”><span class=”subj”>Please list me</span><span class=”tit”>contact us</span></span>.<span class=”mailme”></span><span class=”mailme_extra”><span class=”subj”></span><span class=”tit”></span></span>
I did something to avoid regex, but its too long, wrong, and I am sure wont work:
I have been able to reach some results but not what I need below:
[code=php] function safe_emailto($content) {
$email_patt = ‘([A-Za-z0-9._%-]+)@([A-Za-z0-9._%-]+).([A-Za-z0-9._%-]+)’;
$mailto_pattern = ‘#<a[^>]*?href=”mailto:%5cs?’ . $email_patt . ‘?subject=([A-Za-z0-9._%-]+)[^>]*?>[^>]*?</a>#’;
$rewrite_result = ‘<span class=”mailme”>$1 AT $2 DOT $3</span><span class=”mailme_extra”><span class=”subj”>$4</span><span class=”tit”>$5</span></span>’;
$content = preg_replace($mailto_pattern, $rewrite_result, $content);
$content = preg_replace(‘#’ . $email_patt . ‘#’, $rewrite_result, $content);
return $content;
}
Can someone help me out here.
Basically wont show $5 and $4 only works if there is no space between the subject.