CFLib.org – Common Function Library Project

ReMatch(RegEx, Txt)

Last updated May 9, 2009

author

John Bartlett

Version: 0 | Requires: CF5 | Library: StrLib

Description:
Provides the ReMatch function for MX6 and MX7. Not for use on MX8 (built in function).

Return Values:
Returns an array

Example:

ReMatch("(ABC|DEF|GHI|JKL)","ABCDEFGHIJKL")

Parameters:

Name Description Required
RegEx regular expression for which to search Yes
Txt search string Yes

Full UDF Source:

/**
 * Provides the CF8 ReMatch functionality in MX6/MX7
 * 
 * @param RegEx 	 regular expression for which to search (Required)
 * @param Txt 	 search string (Required)
 * @return Returns an array 
 * @author John Bartlett (jbartlett@strangejourney.net) 
 * @version 0, May 9, 2009 
 */
function ReMatch(RegEx,Txt)
{
	var MatchList=ArrayNew(1);
	var tmp="";
	var Done=0;
	var StartPos=1;
	Arguments.Txt=Arguments.Txt & " ";

	while (NOT Done) {
		tmp=ReFind(Arguments.RegEx,Arguments.Txt,StartPos,"true");
		if (tmp.Pos[1] EQ "0") {
			Done=1;
		} else {
			MatchList[ArrayLen(MatchList) + 1]=Mid(Arguments.Txt,tmp.Pos[1],tmp.Len[1]);
			StartPos=tmp.Pos[1] + Tmp.Len[1];
		}
	}
	return MatchList;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson