Regular Expressions

A regular expression is a sequence of characters that can match one or more target sequences of characters, according to a regular expression grammar. This implementation supports the following regular expression grammars:

  • BRE — Basic Regular Expressions, defined by the POSIX Standard, Part 1 (ISO/IEC 9945-1:2003)
  • ERE — Extended Regular Expressions, also defined by the POSIX Standard, Part 1
  • ECMAScript — ECMAScript regular expressions, as defined by the ECMAScript Language Specification (Ecma-262)
  • awk — regular expressions as used in the awk utility, defined by the POSIX Standard, Part 3 (ISO/IEC 9945-3:2003)
  • grep — regular expressions as used in the grep utility, also defined by the POSIX Standard, Part 3
  • egrep — regular expressions as used in the grep utility with the -E option, also defined by the POSIX Standard, Part 3

This document describes each of these grammars as provided in this implementation. Most of the differences between the grammars are in the regular expression features that are supported. When features are not supported by all of the grammars the text describing those features lists the grammars that support them. In some cases the differences between the grammars are in the syntax used to describe a feature (for example, BRE and grep require a backslash in front of a left parenthesis that marks the beginning of a group and the others do not). In these cases the differences are described as part of the description of the feature.

Copyright note

Certain materials included or referred to in this document are copyright P.J. Plauger and/or Dinkumware, Ltd. or are based on materials that are copyright P.J. Plauger and/or Dinkumware, Ltd.

Notwithstanding the meta-data for this document, copyright information for this document is as follows:

Copyright © IBM Corp. 1999, 2013. & Copyright © P.J. Plauger and/or Dinkumware, Ltd. 1992-2006.