lookahead and group
Posted
by Istao
on Stack Overflow
See other posts from Stack Overflow
or by Istao
Published on 2010-05-21T09:29:47Z
Indexed on
2010/05/21
10:00 UTC
Read the original article
Hit count: 216
Hi,
In Java, on a text like foo <on> bar </on> thing <on> again</on> now
, I should want a regex with groups wich give me with a find "foo", "bar", empty string, then "thing", "again", "now".
If I do (.*?)<on>(.*?)</on>(?!<on>)
, I get only two group (foo bar, thing again, and I've not the end "now").
if I do (.*?)<on>(.*?)</on>((?!<on>))
I get foo bar empty string, then thing again and empty string (here I should want "now").
Please what is the magical formula ?
Thanks.
© Stack Overflow or respective owner