Sorry if this a duplicate, I didn't find similar question, maybe I missed something...
I will explain what I want by example:
Suppose we have a simple regular expression for checking email
private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
I start to enter (in some input field) email (or not email, but some string) symbol by symbol and check whole line by regex.
- Enter: u
- Line: u
- Check:
true \\ because there is a chance that I will enter right symbols further
- Enter: s
- Line: us
- Check:
true
...
- Enter: @
- Line: username@
- Check:
true
- Enter: @
- Line: username@@
- Check:
false \\ because there is no way to get correct line appending any symbols
- Enter: d
- Line: username@d
- Check:
true
- Enter: .
- Line: username@domain.
- Check:
true
- Enter: .
- Line: username@domain..
- Check:
false
By other words I want to check string by regex and get positive result if there is possibility that appending symbols will give us correct string.