in reply to Re: filtering folder path using regex.
in thread filtering folder path using regex.

Thanks Sir,

the $path =~ /^(\w):\\(^\\+)\\?/ worked for me, but what I don't understand how does it get the $2 value? There is no “.” or “\w” in the second parenthesis. Oh well, as long as it works…
  • Comment on Re: Re: filtering folder path using regex.

Replies are listed 'Best First'.
Re: Re: Re: filtering folder path using regex.
by tcf22 (Priest) on Jul 13, 2003 at 18:55 UTC
    I think you were talking about this one:
    $path =~ /^(\w):\\([^\\]+)\\?/;
    In this one [\\] would match just backslashes, but with the ^, [^\\], matches all characters Except backslashes, and because of the +, it matches as much as possible up to the 1st backslash. $2 is populates, because the character class (ie. [^\\]) is in parenthesis, which happens to be the second set of them, so therefore is stored in $2
      Spot on with your explanation kind sir.
      [] and ^ means all Except backslashes,...I confused it with ^ as an anchor or start of a word boundary....I should’ve been more careful when constructing a Regex expressions!…

      Thanks for reminding me....

      & I should always keep practice coding.