SergioQ has asked for the wisdom of the Perl Monks concerning the following question:
Yes, I realize that Perl regex is not the way to go to find links. But I have a small amount of text with just a few links, some divisions, etc.and my method works.
($mres) = ($res =~ m/(<a href=\"https:\/\/www.example.com\/foodbanks\/ +.*<\/a>)/im);
However if the link itself has a '+' right before the then my match returns much more text ending with the last it can find, even though I'm not using /g
When I add the '+' in my code:
($mres) = ($res =~ m/(<a href=\"https:\/\/www.example.com\/foodbanks\/ +.*\+<\/a>)/im);
Everything comes out fine, and I just get the single link.
I'd love to know why.
p.s. The forum adds a red + to lines here that "wrap" so it makes my code look more confusing.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: If I'm matching a pattern wy does a + sign make things crazy?
by Corion (Patriarch) on May 05, 2020 at 08:42 UTC | |
|
Re: If I'm matching a pattern wy does a + sign make things crazy? (updated)
by haukex (Archbishop) on May 05, 2020 at 08:52 UTC | |
|
Re: If I'm matching a pattern why does a + sign make things crazy?
by Athanasius (Archbishop) on May 06, 2020 at 13:56 UTC | |
|
Re: If I'm matching a pattern wy does a + sign make things crazy?
by AnomalousMonk (Archbishop) on May 05, 2020 at 20:52 UTC | |
|
Re: If I'm matching a pattern wy does a + sign make things crazy?
by AnomalousMonk (Archbishop) on May 05, 2020 at 21:57 UTC |