Closed bert-at-github closed 4 years ago
Sorry, looks like escape char backslash has been stripped from the pattern and perl code when pasting.
The pattern from the XSD looks like this:
<xs:pattern value="[A-Z0-9'\-/\.]{1}[A-Z0-9'\-/\.\s]{0,}"/>
and the working Perl code looks like this:
if ($text =~ m!^[A-Z0-9'\-/\.]{1}[A-Z0-9'\-/\.\s]{0,}$!) {
and the JDoodle input is:
public static String PATTERN = "[A-Z0-9'\\-/\\.\\s]{0,20}";
Thank you for reporting this. I'll take care of that.
Hey. Issue is fixed. Please verify it on your end.
You can get version with fix from snapshots repository: https://oss.sonatype.org/content/repositories/snapshots/
using this dependency
<dependency>
<groupId>com.github.curious-odd-man</groupId>
<artifactId>rgxgen</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
Great, I can confirm this is now working correctly in the snapshot version. Thank you for this very fast response.
Closing as confirmed by the reporter. Commit 8790fb36481f00f9c9aa5c4319a42229bc96eee2
The regex pattern, taken from a 3th party XmlSchema, throws an exception class DefaultTreeBuilder. The definition in the XSD is:
The exception is: Exception in thread "main" java.lang.RuntimeException: Multiple nodes found inside square brackets escape sequence before '/.\s]{0,2 at 15' at com.github.curiousoddman.rgxgen.parsing.dflt.DefaultTreeBuilder.handleCharacterVariations(DefaultTreeBuilder.java:404) ...
This regex works as expected when used in Perl like: if (m!^[A-Z0-9'-/.]{1}[A-Z0-9'-/.\s]{0,}$!) { ... }
The issue is reproducible in https://www.jdoodle.com/a/1NCw by setting: public static String PATTERN = "[A-Z0-9'\-/\.\s]{0,}"; (only the last part of the pattern is used, as this is where the problem comes from).
The problem seems to be the \s inside the brackets [ ].
By removing this whitespace char class, the parsing of the remaining regex is ok.