in reply to Global regex giving up too soon

First of all, the /c modifier is meaningless with s///. Had you turned on warnings, Perl would have told you so. Furthermore, the regex matches from the "href" to the final ">", and you replace everything, but the second quote. For the given example string, there's only one "href", so the /g is pointless as well.

I can't figure out what your intention is, so I'm not offering a working regex.

Abigail

Replies are listed 'Best First'.
Re: Re: Global regex giving up too soon
by Wassercrats (Initiate) on Jan 20, 2004 at 11:24 UTC
    For the given example string, there's only one "href", so the /g is pointless as well.

    I figured that was my problem. That's why I tried using /c, but I couldn't find a good description of how it worked. So basically, I guess there is no way to get /g to look over the entire regex, so I'll have to use while $& or establish that there's an href earlier so I don't have to use it in the regex.

    Anyway, thanks for not telling me to use a module!

      So basically, I guess there is no way to get /g to look over the entire regex,
      What do you mean by "looking over the entire regex"? /g means "match repeatedly (without overlap)".

      Abigail

        Well, does it make sense that there is a substitution made in more than one iteration of my loop, but if I use the regex alone, there are fewer (only one) substitutions made?