in reply to Re: Annoying Regex issue with forign chars
in thread Annoying Regex issue with forign chars

Hi, Also, regarding your suggestion of: $desc =~ s|(<=\s)$_(<=\s)|<a href="$hit->{LinkURL}" target="$hit->{Target}">$_</a>|sg; ...is that what you mean? TIA Andy

Replies are listed 'Best First'.
Re^3: Annoying Regex issue with forign chars
by ultranerds (Hermit) on Nov 05, 2008 at 12:21 UTC
    Hi, Ok, this seems to be working ok (and should do what I need);

    $desc =~ s|([\s\.]?)$_([\s\.]?)|$1<a href="$hit->{LinkURL}" title="$hit->{TheText}" target="$hit->{Target}">$_</a>$2|sg;


    Thanks for the help guys :)

    Cheers Andy
      Bugger, that had an undesired effect :(

      It was converting words insde the <a href, and giving really weird output.

      Only way I eventually got it to work was wit this bit of messy code:
      if ($hit->{TheText}) { $desc =~ s|\Q $_ | <a href="$hit->{LinkURL}" title="$hit-> +{TheText}" target="$hit->{Target}">$_</a> |sg; $desc =~ s|\Q $_\E$| <a href="$hit->{LinkURL}" title="$hit +->{TheText}" target="$hit->{Target}">$_</a>|sg; $desc =~ s|\Q $_,| <a href="$hit->{LinkURL}" title="$hit-> +{TheText}" target="$hit->{Target}">$_</a>, |sg; $desc =~ s|\Q. $_ |. <a href="$hit->{LinkURL}" title="$hit +->{TheText}" target="$hit->{Target}">$_</a> |sg; } else { $desc =~ s|\Q $_ | <a href="$hit->{LinkURL}" target="$hit- +>{Target}">$_</a> |sg; $desc =~ s|\Q $_\E$| <a href="$hit->{LinkURL}" target="$hi +t->{Target}">$_</a>|sg; $desc =~ s|\Q $_, | <a href="$hit->{LinkURL}" target="$hit +->{Target}">$_</a>, |sg; $desc =~ s|\Q. $_ |. <a href="$hit->{LinkURL}" target="$hi +t->{Target}">$_</a> |sg; }


      Cheers

      Andy