manpagez: man pages & more
info sed
Home | html | info | man

File: sed.info,  Node: ERE syntax,  Next: Character Classes and Bracket Expressions,  Prev: BRE syntax,  Up: sed regular expressions

5.4 Overview of extended regular expression syntax
==================================================

The only difference between basic and extended regular expressions is in
the behavior of a few characters: ‘?’, ‘+’, parentheses, braces (‘{}’),
and ‘|’.  While basic regular expressions require these to be escaped if
you want them to behave as special characters, when using extended
regular expressions you must escape them if you want them _to match a
literal character_.  ‘|’ is special here because ‘\|’ is a GNU extension
- standard basic regular expressions do not provide its functionality.

Examples:
‘abc?’
     becomes ‘abc\?’ when using extended regular expressions.  It
     matches the literal string ‘abc?’.

‘c\+’
     becomes ‘c+’ when using extended regular expressions.  It matches
     one or more ‘c’s.

‘a\{3,\}’
     becomes ‘a{3,}’ when using extended regular expressions.  It
     matches three or more ‘a’s.

‘\(abc\)\{2,3\}’
     becomes ‘(abc){2,3}’ when using extended regular expressions.  It
     matches either ‘abcabc’ or ‘abcabcabc’.

‘\(abc*\)\1’
     becomes ‘(abc*)\1’ when using extended regular expressions.
     Backreferences must still be escaped when using extended regular
     expressions.

‘a\|b’
     becomes ‘a|b’ when using extended regular expressions.  It matches
     ‘a’ or ‘b’.

© manpagez.com 2000-2026
Individual documents may contain additional copyright information.