我想从给定的匹配中生成正则表达式模式
例如我想得到 <b>\d+<\b>
来自以下匹配数组
<b>1</b><br/>
<b>2</b><br/>
<b>3</b><br/>
<b>4</b><br/>
<b>5</b><br/>
...
有什么想法吗?
最佳答案
工具
来自 answer对于类似的问题,以下链接可能对您有所帮助:
txt2re: Online regular expression generator.
理解
如果您寻求对该主题的更深入理解而不是快速解决方案,您应该阅读以下问题的答案: Is it possible for a computer to “learn” a regular expression by user-provided examples?
编码
如果您想自己编写一个快速解决方案, this answer 值得一看。
注意事项
如有意义的 joke所示,不要忘记 computers cannot read your mind ,并且可以为相同的输入生成多个不同的正则表达式。
关于c# - 从匹配中生成正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12067471/