What is grep or pattern searching?
A grep pattern, also known as a regular expression, describes the text that you're looking for. For instance, a pattern can describe words that begin with C and end in l. A pattern like this would match "Call", "Cornwall", and "Criminal" as well as hundreds of other words.
In fact. you've probably already used pattern searching without realizing it. The Find dialog box's "Match Case" and "Entire Word" options turn on special searching patterns. Suppose that you're looking for "corn". With the "Match Case" option turned off, you're actually looking for a pattern that says: look for a C or c, O or o, R or r, and N or n. With the "Entire Word" option on, you're looking for the string "corn" only if it's surrounded by white space or punctuation characters; special search characters, called metacharacters, are added to the search string you specified to indicate this.
What makes pattern searching counterintuitive at first is how you describe the pattern. Consider the first example above, where we want to search for text that begins with the letter "C" and ends with the letter "l" with any number of letters in between. What exactly do you put between them that means "any number of letters"? That's what this section is all about.
Note - Grep is the name of a frequently-used Unix command that searches using regular expressions, the same type of search pattern used by BBEdit. For this reason, you'll frequently see regular expressions called "grep patterns," as BBEdit does. They're the same thing.
Recommended Books and Resources
Mastering Regular Expressions
by Jeffrey E.F. Friedl. O'Reilly & Associates, 1997. ISBN 1-56592-257-3
Although it does not cover BBEdit's grep features specifically, Mastering Regular Expressions is an excellent resource for learning the "how-to" of writing useful grep patterns.
BBEdit-Talk
The BBEdit-Talk online mailing list covers a wide range of topics and questions about using BBEdit, which frequently include searching and the use of grep patterns. To subscribe to this list, please visit the support section of our Web site, which offers the option to sign up.
http://www.barebones.com/support/lists.html
Tech Note - For the curious reader, BBEdit's grep engine is a variant of Henry Spencer's regexp package, and its behavior is that of a `traditional NFA' engine.