rnaeye has asked for the wisdom of the Perl Monks concerning the following question:
My Regex-1 matches the string although string has a space between "builtin.c \". I do understan why Regex-2 will match and Regex-2 will not. But I do not get why Regex-1 is matching. Please see my commented code for detaisl of the question. Thank you for your wisdom!
#!/usr/bin/perl use warnings; use strict; use 5.010; my $string = 'SRC=array.c builtin.c \ missing.c msg.c'; #Regex-1 Following matches, but WHY? String has a single space between + "builtin.c \" $string =~ m/^\w+=[^\n\\]*\\/; #Regex-2 Following also matches $string =~ m/^\w+=[^\n\\]* \\/; #pay attention to single space between + * and \ #Regex-3 Following does NOT match $string =~ m/^\w+=[^\n\\]* \\/; #pay attention to double spaces betwe +en * and \ say $string;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: help with regex
by graff (Chancellor) on May 05, 2013 at 23:52 UTC | |
by rnaeye (Friar) on May 06, 2013 at 00:23 UTC |