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
listid car van
listid dog cat
listid house hotel
etc....
when i use reMatchNoCase("(lis开发者_如何学Pythontid)","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
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.
This regular expression will probably do; I don't know coldfusion details, but it matches what you want:
listid.*?(?=$|\slistid)
精彩评论