Copy link to clipboard
Copied
I would like to extract the nth occurance of a token from a string based on the position of a pattern matching more than one characters, vs. the single character list of delimiters that GetToken() supports. GetToken() is great in many contexts, but not this one! Haven't found anything in CFLib, but maybe I'm just looking in the wrong places. Seems like it should be a common need.
Copy link to clipboard
Copied
GetToken() and ListGetAt() both will treat multiple delimiter values as individual, not as a pattern.
I wonder if RegEx matching will get at least an index position, which you can use as you describe?
V/r,
^ _ ^
Copy link to clipboard
Copied
Appreciate the input WolfShade. Digging around a bit more came up with a nice component by Ben Nadel that I think meets this need:
RESplit() - Splitting Strings With Regular Expressions In ColdFusion
Copy link to clipboard
Copied
Good find. Ben comes up with some pretty awesome scripts. I especially like his reMultiMatch() function.
V/r,
^ _ ^
Copy link to clipboard
Copied
From your description, I would have thought that REMatch or REMatchNoCase would be suitable. You would then get a result, from which you could simply red off searchMatchArray[n]