A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java in General
Need explanation on how Lookahead example work
Joined: Oct 20, 2006
Aug 18, 2011 08:23:00
I need your advice on explaining how the following regular expression example, illustrated on the last paragraph from
Let's take one more look inside, to make sure you understand the implications of the lookahead. Let's apply q(?=u)i to quit. I have made the lookahead positive, and put a token after it. Again, q matches q and u matches u. Again, the match from the lookahead must be discarded, so the engine steps back from i in the string to u. The lookahead was successful, so the engine continues with i. But i cannot match u. So this match attempt fails. All remaining attempts will fail as well, because there are no more q's in the string.
I just understand how there is a mis-matched between after the lookahead had been discarded. Moreover, what is the correct regular expression?
Thanks a lot,
I agree. Here's the link:
subject: Need explanation on how Lookahead example work
finding regex for extracting a pattern
Seaching and Replacing text program
Need help in understanding greedy, reluctant quantifiers in regular expressions??
reusable Pattern object
Regular expression to check for specific special characters (any repitition) and 0 to 9 numbers
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015