Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^2: how to do match from $li?

by AnomalousMonk (Chancellor)
on Jun 11, 2013 at 11:18 UTC ( #1038235=note: print w/replies, xml ) Need Help??

in reply to Re: how to do match from $li?
in thread how to do match from $li?

Further to davido's point about alternation:
Because it's a point that often escapes people (it's escaped me often enough), I want to emphasize that the effective low precedence of the  | (alternation) regex operator means that the  [A-Z].[a-z] portion of the OPed regex matches independently of the rest of that particular regex. E.g., after fixing the  // delimiter confusion, but leaving the  . (dot) matching as it was:

>perl -wMstrict -le "my $li = 'foo'; ;; print qq{matched '$&' in '$li'} if $li =~ m{http://www.[a-z]|[A-Z].[a-z]}i; " matched 'foo' in 'foo'

NB: Don't get into the habit of using the  $& $` $' special matching variables in your regexes. See the paragraph in perlre that begins "WARNING: Once Perl sees that you need one of $&, $`, or $' anywhere in the program ..." for a discussion of the cost of using them, and also the following paragraph for a workaround available in Perl version 5.10+. Also see the discussion of these variables in perlretut for workarounds using substr that can be used pre-5.10.

Replies are listed 'Best First'.
Re^3: how to do match from $li?
by davido (Archbishop) on Jun 11, 2013 at 15:11 UTC

    Lol. I totally missed the /http//:...../ delimiter bug. It starts looking like an intentional attempt to get it wrong just so we will jump around like our hair is on fire trying to fix it. ...because there really is nothing that is right within it. An honest attempt to get it right would contain at least one portion of the RE that isn't a bug. ;)


      You missed it, because it was not in the question initially. I really hate it, when the question is altered after receiving the first answers. Usually makes the answers looking silly as they point to issues that are not present in the question.

        oOOh! Well that explains why I recommended URI::Find::Schemeless rather than URI::Find.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1038235]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2018-05-23 10:04 GMT
Find Nodes?
    Voting Booth?