Skip to content

Lookaround does not work when it influences other part of pattern #63

@Pigeon-Barry

Description

@Pigeon-Barry

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:

(?!B)[AB]

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:

**Describe the bug** A clear and concise description of what the bug is.

When using

new RgxGen("^((?!(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]?$").generate();

the following String is generated '">MO281733' which does not conform to the regular expression.

To Reproduce
Steps to reproduce the behavior:

  1. 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]?$'

  2. Use code/API - Code

  3. 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

	        <dependency>
			<groupId>com.github.curious-odd-man</groupId>
			<artifactId>rgxgen</artifactId>
			<version>1.3</version>
		</dependency>

Additional context
Add any other context about the problem here.

Metadata

Metadata

Labels

bugSomething isn't workingenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions