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;
In reply to help with regex by rnaeye
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |