Highlighted

GetToken() - like function using a pattern, vs. a collection of delimiters

New Here ,
Nov 20, 2019

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.

 

 

 

 

TOPICS
Advanced techniques

Views

341

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

GetToken() - like function using a pattern, vs. a collection of delimiters

New Here ,
Nov 20, 2019

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.

 

 

 

 

TOPICS
Advanced techniques

Views

342

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 20, 2019 0
LEGEND ,
Nov 21, 2019

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,

 

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 21, 2019 0
New Here ,
Nov 21, 2019

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 21, 2019 0
LEGEND ,
Nov 22, 2019

Copy link to clipboard

Copied

Good find.  Ben comes up with some pretty awesome scripts.  I especially like his reMultiMatch() function.

 

V/r,

 

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 22, 2019 0
BKBK LATEST
Adobe Community Professional ,
Nov 23, 2019

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]

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 23, 2019 0