-1

Given some strings, is there some algorithm (and program that implement such an algorithm) that can create a regex which matches some of the given strings and not the other given strings?

I like the regex can generalize well on other strings not given (just like machine learning algorithms)

I am not restricted to any particular regex flavor. Thanks.

Tim
  • 1
  • 141
  • 372
  • 590
  • 1
    One of such regexes would be `/string1|string2|.../`. If you want anything "smarter" than that, explain how exactly. – georg Mar 14 '15 at 16:53
  • Right. I think i want something smarter than that, probably I should also give some strings that shouldn't be matched. and I like the regex can generalize well on other strings not given (just like machine learning algorithms) – Tim Mar 14 '15 at 16:54
  • Nope, we're not there yet. What you're asking for would be very difficult even for humans, and machine learning usually tries to do well on tasks that humans are good at. – IVlad Mar 14 '15 at 22:30

1 Answers1

1

Take a look at similar questions: first and second.

Someones there argue that it is impossible in principle, others suggest tools for that.

I'm not sure that this link wasn't in these questions, so check it; also try to google by "pattern induction" or "regular expression induction" (example paper for URL regexps).

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Nikita Astrakhantsev
  • 4,701
  • 1
  • 15
  • 26