Linux [Electronic resources]

Janet Valade

نسخه متنی -صفحه : 357/ 261
نمايش فراداده

Match One of a Set of Literal Characters ( [ ] )

You can put a set of literal characters inside square brackets. The pattern matches if any one of the set of characters is found. You can indicate a range of characters within the brackets by using a hyphen (-).

NOTE

If you want to include a hyphen as a literal character, include it at the beginning or the end of the set.

Regular Expression

Match

Not a Match

a[bcd]ef

abef, acef, adef

aef, abcef

a[b-d]ef

abef, acef, adef

aef, abcef

a[,.-]b

a,b, a.b, a-b

ab, axb, a,-b

file[1-2][0-9]?

file1, file15, file20

file, file3, file40