September 12, 2009 at 6:26 pm #7628
thr
Member
Try this:
(rn| )(denk|wil|dacht|kan|wilde|ben|zie)je(?=rn| )
The problem is that your original expression “consumes” both separators, at the beginning of a word and at the end of a word. If the separator at the end of the first word is “consumed” by the expression, it can’t be “consumed” by the expression that should match the second word. Using
(?=rn| )
performs a positive lookahead that only matches but doesn’t “consume” anything. You can write this even simpler, without having to use a positive lookahead, by using constraints (in this case beginning of a word and ending of a word):
<(denk|wil|dacht|kan|wilde|ben|zie)je>