loo
loo

Reputation: 707

match pattern regex coldfusion

i need to match a pattern using reMatchNoCase("(listid)","listid car van listid dog cat listid house hotel")> so listid is the pattern and match that and everything to the next pattern witch is listid again. so if i dump the rematch ill get a structure each starting with listid and the content within

this is what it should look like

  1. listid car van

  2. listid dog cat

  3. listid house hotel

etc....

when i use reMatchNoCase("(listid)","listid car van listid dog cat listid house hotel")> it will only create a structure with "listid" and nothing more like car van... what regex do i use after (listid) to get everything within?

thanks

Upvotes: 0

Views: 1259

Answers (2)

Gopi
Gopi

Reputation: 10293

You can use this regex

listid.*?(?=(listid|$))

What this regex does is locate a 'listid' followed by any characters until next 'listid' or 'end of line ($)'. The ?= is the positive lookahead to look for the next 'listid' but not make it part of the match. The ? in .*? avoids greedy behavior of .* and matches immediate next lookahead string.

Upvotes: 2

Artefacto
Artefacto

Reputation: 97835

This regular expression will probably do; I don't know coldfusion details, but it matches what you want:

listid.*?(?=$|\slistid)

Upvotes: 2

Related Questions