October 1st, 2012, 04:26 PM
Regular expressions not working for grep??
I'm trying to locate any template files in our file hierarchy that contain specific patterns... I'm familiar with regex... have been using it for a few years now with the assistance of regexr...
Now when I try using the syntax found on the man pages and many other how-to sites I never get any results, yet I know there are files with these patterns in them...
What the deal, yo?
Examples of patterns I'm using that simply do not return any results:
grep -r "radius\(" *
grep -r "maximum\-scale\=1" *
grep -r "\d+em\;" *
Any help provided on this matter is greatly appreciated.
October 2nd, 2012, 10:50 AM
So... the man page says to use backslashes to escape these characters... yet people are telling me that is the opposite of what I should be doing...
HOWEVER, this is the story since those updates:
Hmmm isn't this example:
the exact opposite of what the man page says below?
I did read the man page before posting here btw... it doesn't seem to make any sense.
When I try with the backslash in front of the parenthesis this is the return:
I am at the root where many files have multiple lines of CSS3 border-radius styles containing the exact spelling and capitalization as: "-radius(" -In fact I can look them up and open them in the folder tree using vi or nano... however this returns 0 results:
October 2nd, 2012, 11:33 AM
You're misreading the man-page, though it might be clearer with an example.
In basic regexps (i.e. if you don't use the -e flag), they lose the special meanings that they normally have when used in regular expressions (i.e. they match the literal characters). Putting a backslash before a '(' character in basic mode turns it into a regular expression meta-character so the regexp engine expects that group to be closed with a corresponding '\)'. The is the opposite behaviour that you'd expect if you're used to PCREs.
Comments on this post