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?

Replies are listed 'Best First'.
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).