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

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Owner of this card:

Avatar
Andreas Robecke
Last edit:
6 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