Using POSIX extended regular expressions

POSIX extended regular expressions (PERE) is a way to describe string using wildcards and pattern. The following description doesn’t provide a full description of PERE but just intend to help you at the beginning.

the following rules are available:

a|bsearch for a or b
absearch for the symbol a followed by symbol b
.this symbol match any other.
a*symbol a from 0 upto unlimited times.
[abc]search for a or b or c
[a-z]search for symbol between a (included) and z (included).
[^a-z]search for symbol not between a (included) and z (included).
(abc)orabcword abc
^abcsearch for line beginning by the word abc.
abc$search for line ending by the word abc.

You can mix these rules as you need.

Here is some samples:

  • (toto|titi): match any line containing word toto or word titi.
  • ^A[c-t]*O: find line beginning by an A followed by 0 or more letters between c and t and followed by an O.’AkcO‘, ‚AO‘, ‚AdgztrhgtrhthdsfhO‘ matches this pattern.’A O‘, ‚AbO‘, ‚Acdef‘ doesn’t.
  • ^A(toto|titi)*.B*O$: find line beginning by an A followed by 0 or more word toto or titi followed by 1 undefined character followed by 0 or more letter B and ending by an O.’A O‘, ‚Atototototiti BBBBBBBO‘ matches this pattern.’A Ok‘, ‚BO‘ doesn’t.