Extended Regular Expressions Characters
+ : Repeat the previous RE character of one or more.
Example : Search for "god" "good" "goood"... etc. strings.
egrep -n 'go+d' regular_express.txt
? : Zero or one before the RE character.
Example: Search for the two strings "gd" and "god".
egrep -n 'go?d' --color=auto regular_express.txt
| : Find out several strings by OR.
Example: Search for the two strings "gd" or "good".
egrep -n 'gd|good' --color=auto regular_express.txt
() : Find group string.
Example: Search for the two strings "glad" or "good", because "g" and "d" are duplicates, so I can list "la" and "oo" in () and separate them with |
egrep -n 'g(la|oo)d' --color=auto regular_express.txt
()+ : Identification of multiple repeated groups.
Example: I'm looking for a string that starts with "A" and ends with "C", and there is more than one "xyz" string in the middle.
echo 'AxyzxyzxyzC' | egrep 'A(xyz)+C' --color=auto
Comments
Post a Comment