开发者

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("(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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜