I have a problem with what I consider the difference in grep and perl regex regex. Consider the following small test:
$ cat testfile.txt
A line of text
SOME_RULE = $(BIN)
Another line of text
$ grep "SOME_RULE\s*=\s*\$(BIN)" testfile.txt
SOME_RULE = $(BIN)
$ perl -p -e "s/SOME_RULE\s*=\s*\$(BIN)/Hello/g" testfile.txt
A line of text
SOME_RULE = $(BIN)
Another line of text
As you can see, using the regular expression "SOME_RULE \ s * = \ s * \ $ (BIN)", grep could find a match, but perl could not update the file using the same expression. How do I solve this problem?
Thank you for reading and in advance for any help, rate it!
source
share