Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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: (7)
As of 2015-07-03 08:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (49 votes), past polls