News for hackers. Stuff that matters.
Re:Generate Regex from Examples by amelius on Saturday July 25, 2015 @11:27AM (#9947825)
I can't test it right now (site down), but I assume that if I give it the examples 1, 2, 23, 512, 461, 781, it will come up with the regular expression ([0-9]+).

However, it could also have come up with the rule ([0-8]*).

So how does it know which one to choose? Can one also submit counter-examples?

Re:Generate Regex from Examples by jlarocco on Saturday July 25, 2015 @03:07PM (#9948611)
This can't really work 100% without exhaustively giving every string accepted by the regex, or giving every string not accepted by the regex. Regular expressions are essentially a shorthand for doing that.

Since it's impossible to do accurately, it has to use some "common sense" via genetic programming or whatever. In your example, it probably sees that people rarely want [1-8]{1,3}, but that it's a subset of \d+ and goes with that instead.

Re:Generate Regex from Examples by SnaKeZ on Saturday July 25, 2015 @01:50PM (#9948338)
I tried your dataset (exported in JSON): http://pastebin.com/7XU2UfEd

The result is: \d

Re:Generate Regex from Examples by mimmuz on Saturday July 25, 2015 @02:06PM (#9948408)
Some negative examples can help (it is designed to perform a text extraction)
Re:Generate Regex from Examples by mimmuz on Saturday July 25, 2015 @11:37AM (#9947857)
the system tries to generalize, so probably it choose something like \d+ (it is shorter)
Re:Generate Regex from Examples by nothrabannosir on Saturday July 25, 2015 @11:44AM (#9947872)
Depending on unicode settings, \d != [0-9]. See:

http://stackoverflow.com/a/6479605/4359699