Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Avoiding string conversion in H2 tags

Last post 03-01-2008, 8:53 PM by sethson. 0 replies.
Sort Posts: Previous Next
  •  03-01-2008, 8:53 PM 39991

    Avoiding string conversion in H2 tags

    Hi,

    I'm using a PHP script to convert certain strings (for example "ski holiday") to links. The problem is that the strings are also converted if they appear in subheaders (<H2>, example). I only want them converted if they appear in normal text (<P>).

    The script I use (SH Autolink for WordPress) contain the regular expression below, which takes care of converting the strings.

    $strText = preg_replace("|(?!<[^<>]*?)(?<![?./&])\b$strLinkname\b(?!:)(?![^<>]*?>)|imsU","<a target=\"$strTarget\" href=\"".$strProtocol."$strUrl\">$strLinkname</a>" , $strText, 1, $replaceCount);

    How do I modify it, so strings in H2 tags aren't converted?

    Thanks a lot, Brian
     

    Filed under: , , , , ,
View as RSS news feed in XML