in reply to (arturo) Re: matching the non-presence of a string
in thread matching the non-presence of a string

Ah, now I feel silly. You're right, of course. ($!) is what I wanted. My regex has gotten a bit uglier, but it works if I do it this way:

$nomatch="(?!http|telnet|gopher|...|\"|'|\/| )"; . . . ( $nomatch [^'" >]+? ) . . .

I don't quite understand why the $nomatch substitution works, but it's probably something simple too and this is a better solution anyway. I just have one place to update if things need to be changed.

As an aside, since my goal is to re-write the urls in place, I don't see how HTML::LinkExtor would help. I can get the links just fine, I'm just having problems doing the re-writing inline. Am I missing something there?

-J.

Replies are listed 'Best First'.
Re: Re: (arturo) Re: matching the non-presence of a string
by arturo (Vicar) on Mar 21, 2001 at 21:11 UTC
    As an aside, since my goal is to re-write the urls in place, I don't see how HTML::LinkExtor would help. I can get the links just fine, I'm just having problems doing the re-writing inline. Am I missing something there?

    Well, not really I guess. You could try going through line-by-line with a regex, that extracts the links, and then mangles them appropriately in-line. The LinkExtor approach would be to use it to grab all the links, then for each of those links, do an s///g on the text you have (lumped together as a single string) to do the URL mangling. This way *might be* slower (or impractical for other reasons), but given a choice between speed and correctness, my impulse usually lies with correctness. YMMV, of course!

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor