grep: regex
You can use three different versions of the regular expression syntax in grep
:
- basic:
-G
- extended:
-E
- perl:
-P
Difference between basic and extended:
CopyIn basic regular expressions the meta-characters '?', '+', '{', '|', '(', and ')' lose their special meaning; instead use the backslashed versions '\?', '\+', '\{', '\|', '\(', and '\)'.
Difference between extended (POSIX) and perl (PCRE): E.g. \d
is not supported in POSIX.
This grep command searches for the same pattern in different regular expression versions.
Copygrep -G "[0-9]\{4\}ms" production.log grep -E "[0-9]{4}ms" production.log grep -P "\d{4}ms" production.log
By refactoring problematic code and creating automated tests, makandra can vastly improve the maintainability of your Rails application.