Basic Syntax

At its simplest, a regular expression finds a literal string within another literal string. The syntax of a regular expression can be as simple as the following:

 REFind("b", "abc") 

Although this example is very basic, don't underestimate how powerful regular expressions can really be. How about this one:

 REFind("time", "Now is the time for all good men") 

The returned value is the location of the first occurrence of the regular expression within your string. The resulting value of our first example is "2," and the resulting value of our second example is "12." The value corresponds to the first occurrence of the complete search pattern within the string that you are searching. Returning a value for the occurrence of the search pattern is helpful in that it identifies a successful result. It also enables you to carry out other processing, such as splitting a single value into multiple values at the position of the occurrence of the pattern.

We'll take a look at some much more complex regular expressions in just a minute, but first, we need to discuss the use of metacharacters. They can save you a lot of time in formatting your regular expressions.

Inside ColdFusion MX
Inside Coldfusion MX
ISBN: 0735713049
EAN: 2147483647
Year: 2005
Pages: 579 © 2008-2017.
If you may any questions please contact us: