cfRegeX


Start

In the core CFML RE functions, refind lets you specify a starting character position which allows you to skip the first part of the input text. This is essential to allow for looping through multiple times (since refind can only match once per call).

With cfRegex, this start parameter has been extended to all actions that have a limit parameter, to provide a convenient way to skip text that you do not want the regex pattern to see.

For example, to exclude the first line from a search you might do:

<cfset Something = RegexMatch
    ( pattern = '...'
    , text    = InputText
    , start   = find( Chr(10) , InputText )
    ) />

Start accepts a positive integer to start before - a value of 1 means the start of the string, a value of len(string) is the position before the last character of the string.

The text skipped with the start parameter is not available to lookbehinds, (though this might change in future). (For now, if you need to skip X characters but also need a lookbehind, you can begin your expression with (?s:.){X} - where X is a positive integer.)