-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add ability to define what any character "." means #83
Comments
# Conflicts: # README.md # src/main/java/com/github/curiousoddman/rgxgen/config/RgxGenOption.java # src/main/java/com/github/curiousoddman/rgxgen/nodes/SymbolSet.java # src/main/java/com/github/curiousoddman/rgxgen/parsing/dflt/DefaultTreeBuilder.java # src/test/java/com/github/curiousoddman/rgxgen/util/SymbolSetTestUtils.java
…nyCharacterMeans #83.property to define what any character means
Hello! This is now implemented, though only in a snapshot version. Please feel free to try it out and provide any feedback
Here is a code example (note that API is slightly changed public class Main {
public static void main(String[] args) {
RgxGenProperties properties = new RgxGenProperties();
RgxGenOption.DOT_MATCHES_ONLY.setInProperties(properties, RgxGenCharsDefinition.of("abc"));
RgxGen rgxGen = RgxGen.parse(properties, ".");
String generatedValue = rgxGen.generate(); // Will produce either "a" or "b" or "c".
}
} |
Thank you for the reply. That would also work. You could also consider extending this feature and instead of providing the list of characters that would match the "." you could define the regex that would replace the ".". The workaround I'm using right now is: public class Main {
private static final String DOT_PATTERN = "(?<!\\\\)\\.";
private static final String DOT_REPLACEMENT_PATTERN = "[0-9a-zA-Z]";
public static void main(String[] args) {
RgxGen rgxGen = RgxGen.parse(".".replaceAll(DOT_PATTERN, DOT_REPLACEMENT_PATTERN));
System.out.println(rgxGen.generate());
}
} |
I'd like to use RgxGen to generate file names from patterns provided by users. Some of them are like: ^file.*.txt$
I would be very helpful to be able to limit "any character" to some regex like [a-zA-Z0-9-_] to avoid illegal or not desired characters in the file name. It could be similar to solution used in: https://github.com/Cornutum/regexp-gen/blob/master/README.md#what-matches-dot
The text was updated successfully, but these errors were encountered: