-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lookaround does not work when it influences other part of pattern #63
Labels
Comments
curious-odd-man
changed the title
^((?!(BG|GB|KN|NK|NT|TN|ZZ)|(D|F|I|Q|U|V)[A-Z]|[A-Z](D|F|I|O|Q|U|V))[A-Z]{2})[0-9]{6}[A-D]?$ Generates an invalid String
Lookaround does not work when it influences other part of pattern
Feb 13, 2021
Or, really I could go the easy way first - generate text and then verify that it matches with all lookaround things. if not - regenerate, if yes - then give it away to user. Brute-force, but easiest to implement. I can think about performance improvements for special cases later. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is a general issue with lookaround patterns,
Whenever lookaround pattern part should influence another part of pattern (values that can be produced in another part of pattern) - it does not work correctly.
For example:
In this pattern lookahead part
(?!B)
influences[AB]
part by limiting number of valid values of[AB]
part.This should be supported.
Original request text:
When using
the following String is generated '">MO281733' which does not conform to the regular expression.
To Reproduce
Steps to reproduce the behavior:
With regex pattern
'^((?!(BG|GB|KN|NK|NT|TN|ZZ)|(D|F|I|Q|U|V)[A-Z]|[A-Z](D|F|I|O|Q|U|V))[A-Z]{2})[0-9]{6}[A-D]?$'
Use code/API - Code
See error
Invalid String is returned '">MO281733'
Expected behavior
A clear and concise description of what you expected to happen.
I expect a string such as 'AA222222D' to be return as this is valid against the regex however this is not the case
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
OS: [e.g. iOS] Windows 10
JDK/JRE version
java version "14.0.1" 2020-04-14
Java(TM) SE Runtime Environment (build 14.0.1+7)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)
RgxGen Version or commit id
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: