BackUp LevelNext

Regular Expressions

Most people who have worked with the UNIX operating system or have done Web development using the Perl language will be familiar with regular expressions. ColdFusion supports regular expressions in functions whose names begin with the letters "RE", for example, REFind, REReplace, REFindNoCase, and REReplaceNoCase.

About regular expressions

Regular expressions allow for very powerful and flexible string search and replace operations. In traditional search and replace operations, as in the Find and Replace functions of ColdFusion, developers must provide the exact text to be searched for.

This makes searches for dynamic data very difficult, if not impossible. For example, how can you find the first occurrence in a string of any word that consists entirely of capital letters that has spaces around it? Using regular expressions, the tasks is trivial:

<CFSET IndexOfOccurrence=REFind(" [A-Z]+ ", 
    "Some BIG string")>
<!--- The value of IndexOfOccurrence is 5 --->

Web developers often have to process large amounts of dynamic textual data. Regular expressions can be invaluable to the developer writing complex ColdFusion applications.

Use the case-insensitive functions, REFindNoCase and REReplaceNoCase, for expressions where the search string is likely to be mixed case.

See the following sections for details on using regular expressions in ColdFusion:


BackUp LevelNext

allaire

AllaireDoc@allaire.com
Copyright © 1998, Allaire Corporation. All rights reserved.