| Contents > Developing ColdFusion MX Applications > Using Regular Expressions in Functions > Regular expression syntax > Using character classes |
|
|
|
|
||
In character sets within regular expressions, you can include a character class. You enclose the character class inside square brackets, as the following example shows:
REReplace ("Macromedia Web Site","[[:space:]]","*","ALL")
This code replaces all the spaces with *, producing this string:
Macromedia*Web*Site
You can combine character classes with other expressions within a character set. For example, the regular expression [[:space:]123] searches for a space, 1, 2, or 3. The following example also uses a character class in a regular expression:
<cfset IndexOfOccurrence=REFind("[[:space:]][A-Z]+[[:space:]]",
"Some BIG string")>
<!--- The value of IndexOfOccurrence is 5 --->
The following table shows the character classes that ColdFusion supports. Regular expressions using these classes match any Unicode character in the class, not just ASCII or ISO-8859 characters..
Character class |
Matches |
|---|---|
:alpha: |
Any alphabetic character. |
:upper: |
Any uppercase alphabetic character. |
:lower: |
Any lowercase alphabetic character |
:digit: |
Any digit. Same as \d. |
:alnum: |
Any alphanumeric character. Same as \w. |
:xdigit: |
Any hexadecimal digit. Same as [0-9A-Fa-f]. |
:blank: |
Space or a tab. |
:space: |
Any whitespace character. Same as \s. |
:print: |
Any alphanumeric, punctuation, or space character. |
:punct: |
Any punctuation character |
:graph: |
Any alphanumeric or punctuation character. |
:cntrl: |
Any character not part of the character classes [:upper:], [:lower:], [:alpha:], [:digit:], [:punct:], [:graph:], [:print:], or [:xdigit:]. |
:word: |
Any alphanumeric character, plus the underscore (_) |
ascii |
The ASCII characters, in the Hexadecimal range 0 - 7F |
|
|
||
| Contents > Developing ColdFusion MX Applications > Using Regular Expressions in Functions > Regular expression syntax > Using character classes |
|
|
ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 6.1
Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/regexp13.htm
Comments
hokugawa said on Sep 30, 2003 at 8:44 AM : profit11 said on Jul 15, 2004 at 7:39 PM : Adam Cameron said on Dec 27, 2004 at 7:10 PM :