Posted over 2 years ago. Visible to the public. Repeats.

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:

Copy
In 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.

Copy
grep -G "[0-9]\{4\}ms" production.log grep -E "[0-9]{4}ms" production.log grep -P "\d{4}ms" production.log
Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Avatar
Andreas Robecke
Last edit:
8 months ago
by Henning Koch
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Andreas Robecke to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more