【发布时间】:2016-07-16 06:43:29
【问题描述】:
我收集了来自多个来源的文件。
每个文件都包含如下字符串:
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]-
【问题讨论】:
-
阅读stackoverflow.com/a/5395777/128421。你应该能够基于它构建一些东西。
标签: ruby regex pattern-matching pattern-mining