• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 13. Using Regular Expressions > Some Convenient RegEx UDFs

Some Convenient RegEx UDFs

The listings for this chapter include a file called RegExFunctions.cfm, which creates several user-defined functions (UDFs) that might come in handy when you're working with regular expressions. To use the library, simply <cfinclude> it in your own templates. Table 13.5 lists the functions included in this simple UDF library.

Table 13.5. Functions in UDF Library RegExFunctions.cfm
FUNCTIONDESCRIPTION
reFindString()Performs a regular expression match and returns the matched string. Returns an empty string if no match is found. This is a shortcut for using the pos[1] and len[1] values as shown in Listing 13.3.
reFindMatches()Performs a regular expression match and returns a query object that contains a row for every substring that matched. This is a shortcut for the looping technique shown in Listing 13.5.
adjustNewlinesToLinefeeds()Replaces any CRLF or CR sequences in a chunk of text with LF characters. This is handy when using multiline mode with (?m). Accepts just one argument, str, as shown in the section “Understanding Multiline Mode” in this chapter.



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint