Users Guide

Table Of Contents
594 | External Services Interface Dell PowerConnect ArubaOS 5.0 | [User Guide
z “Regular Expression Repetition Operators” on page 513
z “Regular Expression Anchors” on page 513
z “References” on page 514
Character-Matching Operators
Character-matching operators define what the search will match.
Regular Expression Repetition Operators
Repetition operators are quantifiers that describe how many times to search for a specified string. Use them in
conjunction with the character-matching operators in Table 127 to search for multiple characters.
Table 126 Character-matching operators in regular expressions
Operator Description Sample Result
. Match any one character. grep .ord sample.txt Matches ford, lord, 2ord, etc. in the file
sample.txt.
[ ] Match any one character listed
between the brackets
grep [cng]ord sample.txt Matches only cord, nord, and gord
[^] Match any one character not listed
between the brackets
grep [^cn]ord sample.txt Matches lord, 2ord, etc., but not cord
or nord
grep [a-zA-Z]ord sample.txt Matches aord, bord, Aord, Bord, etc.
grep [^0-9]ord sample.txt Matches Aord, aord, etc., but not 2ord,
etc.
Table 127 Regular expression repetition operators
Operator Description Sample Result
? Match any character one time if it
exists
egrep “?erd” sample text Matches berd, herd, etc., erd
* Match declared element multiple
times if it exists
egrep “n.*rd” sample.txt Matches nerd, nrd, neard, etc.
+ Match declared element one or
more times
egrep “[n]+erd” sample.txt Matches nerd, nnerd, etc., but not erd
{n} Match declared element exactly n
times
egrep “[a-z]{2}erd” sample.txt Matches cherd, blerd, etc., but not
nerd, erd, buzzerd, etc.
{n,} Match declared element at least n
times
egrep “.{2,}erd” sample.txt Matches cherd and buzzerd, but not
nerd
{n,N} Match declared element at least n
times, but not more than N times
egrep “n[e]{1,2}rd” sample.txt Matches nerd and neerd