Udostępnij za pośrednictwem


Regular Expressions

Unless you have previously used regular expressions, the term may be unfamiliar to you. However, you have undoubtedly used some regular expression concepts outside the area of scripting.

Examples of Regular Expressions

For example, you most likely use the ? and * wildcard characters to find files on your hard disk. The ? wildcard character matches a single character in a file name, while the * wildcard character matches zero or more characters. A pattern such as data?.dat would find the following files:

data1.dat

data2.dat

datax.dat

dataN.dat

Using the * character instead of the ? character expands the number of found files. data*.dat matches all of the following:

data.dat

data1.dat

data2.dat

data12.dat

datax.dat

dataXYZ.dat

While this method of searching is useful, it is also limited. The ability of the ? and * wildcard characters introduces the concept behind regular expressions, but regular expressions are more powerful and flexible.

See Also

Other Resources

Introduction to Regular Expressions