REReplaceList(str, oldList, newList)
Last updated May 17, 2007
Version: 1 | Requires: CF5 | Library: StrLib
Description:
RE replace a list list of regular expression with a list of string.
Return Values:
Returns a string.
Example:
Convert HTML to XML:
<cfsavecontent variable="thisComment">
<table border="0">
<tr height="17">
<td width="68" height="17">RE Replace List</td>
<td width="49">HTML to XML (part 1)</td>
</tr>
</table>
</cfsavecontent>
<cfscript>
thisComment = REReplaceList(thisComment, "<table[^>]*>,<tr[^>]*>,<td[^>]*>,</td>,</tr>,</table>", "<XmlRool>,<Row>,<Cell>,</Cell>,</Row>,</XmlRoot>");
</cfscript>
<cfoutput>#htmlCodeFormat(thisComment)#</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
str | String to parse. | Yes |
oldList | List of regular expressions. | Yes |
newList | List of replacements. | Yes |
Full UDF Source:
/**
* RE replace a list list of regular expression with a list of string.
*
* @param str String to parse. (Required)
* @param oldList List of regular expressions. (Required)
* @param newList List of replacements. (Required)
* @return Returns a string.
* @author Tuyen Tran (tuyen.k.tran@gmail.com)
* @version 1, May 17, 2007
*/
function REReplaceList(str, oldList, newList) {
var i = 1;
for (i=1; i lte listLen(oldlist); i=i+1) {
str = REReplace(str, listGetAt(oldList, i), listGetAt(newList, i), "all");
}
return str;
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016