Wednesday, August 03 2005 @ 03:45 AM EDT Contributed by: glosser
Linux.com brings us the next segment of their Command-Line-Interface series.
Most of us probably use regular expressions -- pattern that describes a set of characters -- every day without realizing it. Chances are, however, that you aren't really using them to their full potential.
Consider how you search a file for a word. You probably type something like:
grep expression *.html
This command searches all files in the current directory for the word "expression." This is the simplest form of regular expression: a search for literal characters, which are the letters, numbers, and spaces that make up the search strings. "a", "cat", and "sat on the mat" are all patterns of literal characters.
It's not just grep than uses regular expressions. Most Linux filters (such as sed) use regular expressions, as well as many programming languages, including Perl, JavaScript, and (dare I say it) VBScript.