CFLib.org – Common Function Library Project

ReMatch(RegEx, Txt)

Last updated May 09, 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;
}

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

Created by Raymond Camden / Design by Justin Johnson