0

I find generating regular expressions to be difficult, tedious and error-prone.

Is there a program that can generate a regular expression given input that it must match?

for example, I give the regular expression engine this input:

must match:

foo4
baz2
bar8

does not match:

4
fo4
ba4
barr4
4bar

etc.

is this possible for complex regexes or are there too many permutations and it requires a human to guide the algorithm?

Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
  • 2
    If there was one, then there would be no regex questions on SO. – Idos Apr 05 '16 at 17:45
  • unless ppl really loved generating them by hand – Alexander Mills Apr 05 '16 at 17:47
  • 2
    @AlexMills Oooh ooh! I do! Also, this wouldn't really be very plausible. Such an engine would likely spit out retarded results such as `/^(foo4|baz2|bar8)$/` as that would meet your example criteria. – Joseph Marikle Apr 05 '16 at 17:50
  • no, if you wrote smart engine it would be able to generalize, lol – Alexander Mills Apr 05 '16 at 17:51
  • 2
    If there was a do-what-I-mean-machine then there would be no questions at all at StackOverflow. (I am one of the people who loves to write them, but that's not the point. *Programming* is difficult, tedious and error-prone. Regular expressions just behave like any other aspect of making the computer do things for you.) – Tomalak Apr 05 '16 at 18:02
  • regex-magic: http://www.regular-expressions.info/regexmagic.html – Alexander Mills Apr 05 '16 at 20:47
  • The Regular Expression Generator Visual Studio 2010 Other Versions https://msdn.microsoft.com/en-us/library/aa833197(v=vs.100).aspx – Alexander Mills Apr 05 '16 at 20:47

0 Answers0