RegularExpressions

Regular expressions consist of tree parts:

* atoms

Atoms specify what text should be found

Atoms could be a single characters, a range of characters or dot if you don't know the character. Atoms could be a class ( [[:alpha:]], [[:upper:]], [[:alnum:]])

* repetition operator

Specify how many times character should occur

  • {n} - exact n time
  • {n,} - minimal n time
  • {,n} - n time max
  • {n,o} - between n and o times
  • * - zero or more times
  • + - one or more times
  • ? - zero or one time

* place operator

Specify where to find the next character

  • ^ - beginning of the line
  • $ - end of the line
  • \< - beginning of a word
  • \> - end of a word
  • \A - start of a file
  • \Z - end of a file

* Examples

Searching in text file regfile with grep

grep '^abc' regfile
Page last modified on July 28, 2021, at 03:24 PM
Powered by PmWiki