RFindNoCase(Substr, String[, Spos])
Last updated February 14, 2002
Version: 2 | Requires: CF5 | Library: StrLib
Description:
Returns the last index (case insensitive) of an occurrence of a substring in a string from a specified starting position. (The reverse of find.)
Return Values:
Returns the last position where a match is found, or 0 if no match is found.
Example:
<CFSET STR = "This is the test, the test of all tests.">
<CFSET STR2 = "Ray's World">
<CFOUTPUT>
Test: #RFindNoCase("t",STR)#<BR>
Test2: #RFindNoCase("T",STR)#<BR>
Test3: #RFindNoCase("/",STR2)#<BR>
</CFOUTPUT>
Parameters:
Name | Description | Required |
---|---|---|
Substr | Substring to look for. | Yes |
String | String to search. | Yes |
Spos | Starting position. | No |
Full UDF Source:
/**
* Returns the last index (case insensitive) of an occurrence of a substring in a string from a specified starting position.
* Big update by Shawn Seley (shawnse@aol.com) -
* UDF was not accepting third arg for start pos
* and was returning results off by one.
*
* @param Substr Substring to look for.
* @param String String to search.
* @param Spos Starting position.
* @return Returns the last position where a match is found, or 0 if no match is found.
* @author Charles Naumer (cmn@v-works.com)
* @version 2, February 14, 2002
*/
function RFindNoCase(substr,str) {
var rsubstr = reverse(substr);
var rstr = "";
var i = len(str);
var rcnt = 0;
if(arrayLen(arguments) gt 2 and arguments[3] gt 0 and arguments[3] lte len(str)) i = len(str) - arguments[3] + 1;
rstr = reverse(Right(str, i));
rcnt = findNoCase(rsubstr, rstr);
if(not rcnt) return 0;
return len(str)-rcnt-len(substr)+2;
}
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