Generex generex = new Generex("[0-3]([a-c]|[e-g]{1,2})"); // generate the second String in lexicographical order that matches the given Regex. String secondString = generex.getMatchedString(2); System.out.println(secondString);// it print '0b' // Generate all String that matches the given Regex. List<String> matchedStrs = generex.getAllMatchedStrings(); // Using Generex iterator Iterator iterator = generex.iterator(); while (iterator.hasNext()) { System.out.print(iterator.next() + " "); } // it prints 0a 0b 0c 0e 0ee 0e 0e 0f 0fe 0f 0f 0g 0ge 0g 0g 1a 1b 1c 1e // 1ee 1e 1e 1f 1fe 1f 1f 1g 1ge 1g 1g 2a 2b 2c 2e 2ee 2e 2e 2f 2fe 2f 2f 2g // 2ge 2g 2g 3a 3b 3c 3e 3ee 3e 3e 3f 3fe 3f 3f 3g 3ge 3g 3g 1ee // Generate random String String randomStr = generex.random(); System.out.println(randomStr);// a random value from the previous String list
public RegexPatternKeyAlgorithm( @JsonProperty(value = "pattern", required = true) final String pattern ) { if (StringUtils.isBlank(pattern)) { throw new TorrentClientConfigIntegrityException("peerId algorithm pattern must not be null."); } this.pattern = pattern; this.generex = new Generex(pattern); }
@Override public String generate() { return this.generex.random(); }
public static void main(String[] args) { Generex generex = new Generex("[0-3]([a-c]|[e-g]{1,2})"); // generate the second String in lexicographical order that match the // given Regex. String secondString = generex.getMatchedString(2); System.out.println(secondString);// it print '0b' // Generate all String that matches the given Regex. //List<String> matchedStrs = generex.getAllMatchedStrings(); // Using Generex iterator Iterator iterator = generex.iterator(); while (iterator.hasNext()) { System.out.print(iterator.next() + " "); } // it prints: // 0a 0b 0c 0e 0ee 0ef 0eg 0f 0fe 0ff 0fg 0g 0ge 0gf 0gg // 1a 1b 1c 1e 1ee 1ef 1eg 1f 1fe 1ff 1fg 1g 1ge 1gf 1gg // 2a 2b 2c 2e 2ee 2ef 2eg 2f 2fe 2ff 2fg 2g 2ge 2gf 2gg // 3a 3b 3c 3e 3ee 3ef 3eg 3f 3fe 3ff 3fg 3g 3ge 3gf 3gg // Generate random String String randomStr = generex.random(); System.out.println(randomStr);// a random value from the previous String // list } }
public RegexPatternPeerIdAlgorithm( @JsonProperty(value = "pattern", required = true) final String pattern ) { if (pattern == null) { throw new TorrentClientConfigIntegrityException("peerId algorithm pattern must not be null."); } this.pattern = pattern; this.generex = new Generex(pattern); }
@Override public String generate() { return this.generex.random(); }
public static void main(String[] args) { Generex generex = new Generex("[0-3]([a-c]|[e-g]{1,2})"); // generate the second String in lexicographical order that match the // given Regex. String secondString = generex.getMatchedString(2); System.out.println(secondString);// it print '0b' // Generate all String that matches the given Regex. //List<String> matchedStrs = generex.getAllMatchedStrings(); // Using Generex iterator Iterator iterator = generex.iterator(); while (iterator.hasNext()) { System.out.print(iterator.next() + " "); } // it prints: // 0a 0b 0c 0e 0ee 0ef 0eg 0f 0fe 0ff 0fg 0g 0ge 0gf 0gg // 1a 1b 1c 1e 1ee 1ef 1eg 1f 1fe 1ff 1fg 1g 1ge 1gf 1gg // 2a 2b 2c 2e 2ee 2ef 2eg 2f 2fe 2ff 2fg 2g 2ge 2gf 2gg // 3a 3b 3c 3e 3ee 3ef 3eg 3f 3fe 3ff 3fg 3g 3ge 3gf 3gg // Generate random String String randomStr = generex.random(); System.out.println(randomStr);// a random value from the previous String // list } }
/** * Match a query parameter with a regex. A random query parameter value will be generated from the regex. * * @param parameter Query parameter * @param regex Regular expression to match with */ public PactDslRequestWithPath matchQuery(String parameter, String regex) { return matchQuery(parameter, regex, new Generex(regex).random()); }
/** * Match a response header. A random example header value will be generated from the provided regular expression. * * @param header Header to match * @param regexp Regular expression to match */ public PactDslResponse matchHeader(String header, String regexp) { return matchHeader(header, regexp, new Generex(regexp).random()); }
/** * Match a request header. A random example header value will be generated from the provided regular expression. * * @param header Header to match * @param regex Regular expression to match */ public PactDslRequestWithPath matchHeader(String header, String regex) { return matchHeader(header, regex, new Generex(regex).random()); }
/** * Match a query parameter with a regex. A random query parameter value will be generated from the regex. * * @param parameter Query parameter * @param regex Regular expression to match with */ public PactDslRequestWithPath matchQuery(String parameter, String regex) { return matchQuery(parameter, regex, new Generex(regex).random()); }
/** * Match a request header. A random example header value will be generated from the provided regular expression. * * @param header Header to match * @param regex Regular expression to match */ public PactDslRequestWithPath matchHeader(String header, String regex) { return matchHeader(header, regex, new Generex(regex).random()); }