wtd
|
Posted: Sat Nov 13, 2004 8:35 pm Post subject: [Regex-tut] What are regular expressions? |
|
|
What are regular expressions?
Regular expressions, in practical terms, are a means of performing pattern matching against strings.
Rather than simply comparing two strings for equality, or even comparing ranges of them, regular expressions allow programmers a way to relatively construct powerful, truly flexible patterns. They allow us to not just make simple comparisons, but to identify whole classes of strings.
What do you need?
Regular expressions are almost like a programming language by themselves. The regular expressions I'll be talking about are Perl-compatible. They're so named because the Perl programming language borrowed ideas about regular expressions from various sources and then, because of the popularity of Perl, it created something of a standard for what regular expressions should be.
Many programming languages support the use of Perl-compatible regular expressions. In particular, Perl, Ruby, Python, Java, and C#. Others possess libraries for regular expressions, but don't make them as easy to deal with. Of the five mentioned, only Perl and Ruby feature particular syntax for the creation and use of regular expressions.
For the purposes of demonstrating regular expressions, I'll be using Ruby. |
|
|