The simplest way to search for a pattern is to look for a single character. For example, you might want to know if a certain string begins with the letter b, ends with the letter t, and contains exactly one character between. Although you could repetitively check every three-character string that begins with b and ends with t, like bat or but, it’s much easier to use a single-character wildcard instead, which is a dot or period character (.).

 

Before you can manipulate a string, you first must find it. Although some programming languages include string searching functions, most of them are fairly limited to finding exact matches of strings. To remedy this problem, many programming languages such as Perl and Tcl use regular expressions. A regular expression is just a series of symbols that tell the computer how to find a specific pattern in a string.

 

If a programming language doesn’t offer built-in support for regular expressions, many programmers have written subprogram libraries that let you add regular expressions to your program. By using regular expressions, your programs can perform more sophisticated text searching than any built-in string functions could ever do. To search for multiple characters, use the (.) wildcard multiple times to match multiple characters.

𐌢