Register / Login
Java in General
Need explanation on how Lookahead example work
posted 5 years ago
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,
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