Chapter 10. Regular Expressions


graphics/chic01.gif

If you've never worked with regular expressions, you might not have any idea what they are, how they work, or what a powerful weapon they are to have in your arsenal. Regular expressions might be second nature to programmers who have come to ColdFusion from other programming backgrounds. They're used extensively in languages such as Visual C++, Tcl, Java, and Perl, and they also can be used in JavaScript.

Regular expressions are used in ColdFusion to parse text, to find patterns or substrings within a string, and to replace patterns or substrings within a string. Regular expressions can be made up of letters, numbers, punctuation characters, and other special characters and metacharacters.

Metacharacters are the special characters that perform functions within a regular expression. They can also be characters within the string for which you're searching, but they must be escaped to be considered a literal character.

There are four native ColdFusion functions that enable ColdFusion programmers to utilize the power of regular expressions to help solve complex search and parsing problems. There are two functions for finding patterns within string: REFind() and REFindNoCase(). In addition, there are two more that find and replace patterns within a string: REReplace() and REReplaceNoCase(). Each function enables you to do some very powerful things with your code.

As we proceed through this chapter, you'll learn more about the basic use and syntax of regular expressions, the metacharacters that we mentioned, and how to leverage regular expressions within your ColdFusion applications.



Inside ColdFusion MX
Inside Coldfusion MX
ISBN: 0735713049
EAN: 2147483647
Year: 2005
Pages: 579

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net