Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Related:</p> <p>A library that generates data matching a regular expression (with limitations): <a href="http://code.google.com/p/xeger/" rel="nofollow noreferrer">http://code.google.com/p/xeger/</a></p> <p>Several solutions, such as conversing a regex into a grammar: <a href="https://stackoverflow.com/questions/22115/using-regex-to-generate-strings-rather-than-match-them">Using Regex to generate Strings rather than match them</a></p> <hr> <p><strong>EDIT:</strong> Actually, <strong>you can make it work!!!</strong> The only thing to address is to impose some domain-specific constraints to preclude combinatorial explosion like a+. </p> <p>If you add to the Xeger class something like this:</p> <pre><code>public void enumerate() { System.out.println("enumerate: \"" + regex + "\""); int level = 0; String accumulated = ""; enumerate(level, accumulated, automaton.getInitialState()); } private void enumerate(int level, String accumulated, State state) { List&lt;Transition&gt; transitions = state.getSortedTransitions(true); if (state.isAccept()) { System.out.println(accumulated); return; } if (transitions.size() == 0) { assert state.isAccept(); return; } int nroptions = state.isAccept() ? transitions.size() : transitions.size() - 1; for (int option = 0; option &lt;= nroptions; option++) { // Moving on to next transition Transition transition = transitions.get(option - (state.isAccept() ? 1 : 0)); for (char choice = transition.getMin(); choice &lt;= transition.getMax(); choice++) { enumerate(level + 1, accumulated + choice, transition.getDest()); } } } </code></pre> <p>... and something like this to XegerTest:</p> <pre><code>@Test public void enumerateAllVariants() { //String regex = "[ab]{4,6}c"; String regex = "34\\.25\\.14\\.(227|228|229|230|243|244|245|246)"; Xeger generator = new Xeger(regex); generator.enumerate(); } </code></pre> <p>... you will get this:</p> <pre><code>------------------------------------------------------- T E S T S ------------------------------------------------------- Running nl.flotsam.xeger.XegerTest enumerate: "34\.25\.14\.(227|228|229|230|243|244|245|246)" 34.25.14.227 34.25.14.228 34.25.14.229 34.25.14.243 34.25.14.244 34.25.14.245 34.25.14.246 34.25.14.230 Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.114 sec </code></pre> <p>... and, guess what. For "[ab]{4,6}c" it correctly produces 112 variants.</p> <p>It's really a quick and dirty experiment, but it seems to work ;).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload