|
|
|
|
|
by wruza
1435 days ago
|
|
Btw, does anyone know a library/program which can reverse engineer a regex from multiple source strings? E.g. 14:51 [info] 51 some message
… more of 51 lines …
15:22 [error] 24 error!
… more of 24 lines …
^(\d\d:\d\d) \[(info|error)\] (\d+) (.+)$
Or maybe not a regex, but a structured pattern. |
|
This could be built using set operations on deterministic finite automata (dfa). Every regex is equivalent to a dfa. You can now construct automata for every positive and negative example input. Then calculate the union for all positive examples and the union for all negative examples. And finally calculate the difference between the two unions. Convert the resulting automaton back to regex.
https://scanftree.com/automata/dfa-union-property