Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Regex failing when the line starts with "./"

by elef (Friar)
on Feb 03, 2011 at 10:53 UTC ( #885966=note: print w/ replies, xml ) Need Help??


in reply to Re: Regex failing when the line starts with "./"
in thread Regex failing when the line starts with "./"

I'm trying to wrap my head around this and it's not coming together.
Wouldn't (?:\.\\|\./) mean "full stop, then either backslash or dot, then forward slash"?
I have no time to test this now, but it seems to me that the correct regex would be:
$line =~ m{(?:\.\\)|(?:\./)(.*);};
with grouping on either side of the |. Or does a | placed within grouping parentheses always match the entire first/second half of the grouping?


Comment on Re^2: Regex failing when the line starts with "./"
Select or Download Code
Re^3: Regex failing when the line starts with "./"
by Anonymous Monk on Feb 03, 2011 at 12:33 UTC
    Wouldn't (?:\.\\|\./) mean "full stop, then either backslash or dot, then forward slash"? ... Or does a | placed within grouping parentheses always match the entire first/second half of the grouping?

    It is second case: [.\\] is one group of regex, [./] is the other.

    To match per your first query, regex would be qr{[.] (?: \\ | . ) /}x (which I would rather write as qr{[.] [.\\] /}x but that is besides the point).

      Carp! Please change ...

      [.\\] is one group of regex, [./] is the other

      ... to ...

      .\\ is one group of regex, ./ is the other

        I give up (and wish I had remembered the password).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://885966]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2014-08-20 23:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (125 votes), past polls