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

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

Replies are listed 'Best First'.
Re^4: Annoying Regex issue with forign chars
by ultranerds (Hermit) on Nov 05, 2008 at 14:41 UTC
    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