in reply to Re: url to html regex problem
in thread url to html regex problem

Replacing ^ with \b is no good because of the presence of links as well as naked urls in the text. My previous reply shows why. You're right that the problem is urls at the beginning of a line in the middle of a string. I've tried both the m and s modifier with no luck. Like I said, it's baffling.

Replies are listed 'Best First'.
Re: Re: Re: url to html regex problem
by suaveant (Parson) on Oct 05, 2001 at 23:30 UTC
    Well... if urls are always preceded by a > you could do a negative lookahead for a >... but that isn't the greatest...

                    - Ant
                    - Some of my best work - Fish Dinner

      I'd tried negative lookahead before without success. But your suggestion made me try harder and I finally got it to work! I had a problem with the order of the characters in $junk being strangely significant until I switched to single quotes:
      my $junk = '<>]="\''; $text =~ s{(?!$junk)\b($urls:[$any] +?)(?=[$punc]* [^$any]|$) }{<a hre +f="$1">$1</a>}migox;
      /me hugs suaveant