Up until now we have covered all the characters used under basic regular expressions (BRE). Here, we'll go over extended regular expressions (ERE), which can be used with
Here is a list of similarities and differences between ERE's and BRE's:
Rather than symbols for backreferences, parentheses in ERE are used for groupings. This allows you to specify groups of text as regular expressions, which is helpful for metacharacters to reference a group of previous regex.
For example, (toy)* would select the letters toy zero or many times.
There are three extended metacharacters that ERE offers.
The ? matches zero or one of the preceding regex.
The plus symbol (+) is used to match one or more of the preceding regex. It's very similar to the asterisk (*), but allows for no NUL values.
$ ls /usr/bin | grep -E '[[:alpha:]][[:digit:]]+[[:alpha:]]' enc2xs5.16 enc2xs5.18 eqn2graph find2perl find2perl5.16 find2perl5.18 grap2graph h2ph h2ph5.16 h2ph5.18 h2xs h2xs5.16 h2xs5.18 hdxml2manxml headerdoc2html ip2cc
This would select all text with a letter, followed by one or more digits, then another letter. We could have gotten the same result with [[:alpha:]][[:digit:]][[:digit:]]*[[:alpha:]] but the previous example looks must cleaner.
Alternations give you the flexibility of choosing between two or more regex expressions.
$ ls /usr/bin/ | grep -E 'zip|pod|enc'
bunzip2 bzip2 bzip2recover enc2xs enc2xs5.16 enc2xs5.18 encode_keychange funzip gencat gunzip gzip latency pod2html pod2html5.16 podchecker5.18 podselect podselect5.16 podselect5.18 unzip unzipsfx uuencode weblatency.d zip zipcloak zipdetails zipdetails5.16 zipdetails5.18 zipgrep zipinfo zipnote zipsplit
This foam seat cushion relieves lowerback pain, numbness and pressure sores by promoting healthy weight distribution, posture and spine alignment. Furthermore, it reduces pressure on the tailbone and hip bones while sitting. Perfect for sitting on the computer desk for long periods of time.$ Check price
This book approaches system administration in a practical way and is an invaluable reference for both new administrators and experienced professionals. It details best practices for every facet of system administration, including storage management, network design and administration, email, web hosting, scripting, and much more.$ Check price