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.
In reply to Re^2: how to do match www.jkghfdjbh.org from $li?
by AnomalousMonk
in thread how to do match www.jkghfdjbh.org from $li?
by virudinesh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |