0
我有来自多个来源的文件的集合。是否可以读取字符串的集合并返回Regexp?
每个文件都包含像字符串:
File 1: A) B) C) D) E)
File 2: a) b) c) d) e)
File 3: a. b. c. d. e.
File 4: a- b- c- d- e-
(...)
我知道我可以事先编写所有可能的模式,但我宁愿自动进行的。
是否可以让程序读取文件和图的模式? 例如:
File 1: A) B) C) D) E) # => [ABCDE]\)
File 2: a) b) c) d) e) # => [abcde]\)
File 3: a. b. c. d. e. # => [abcde]\.
File 4: a- b- c- d- e- # => [abcde]-
取决于你想要做什么[这里](http://www.regexformat.com/version_files/Rx5_ScrnSht01.jpg)和[这里](http://www.regexformat.com/Dnl/_Samples/_Ternary_Tool %20(词典)/ ___ TXT /)。通过三元树创建正则表达式树。 – sln
可能的重复:http://stackoverflow.com/questions/616292/is-it-possible-for-a-computer-to-learn-a-regular-expression-by-user-provided-e – Amadan
阅读http:///stackoverflow.com/a/5395777/128421。你应该能够基于它建立一些东西。 –