我有一段是这样的:
An automobile, autocar, motor car or car is a wheeled motor vehicle used for transporting passengers, which also carries its own engine or motor. Most definitions of the term specify that automobiles are designed to run primarily on roads, to have seating for one to eight people, to typically have four wheels, and to be constructed principally for the transport of people rather than goods.
我有一个正则表达式代码,用于将我的单词列表与这个 paragpraph 匹配,但它不起作用:
[[:<:]]((automobile|motor|roads|bycicle)[[:blank:]]*){2,}[[:>:]]
我如何编辑此正则表达式代码以匹配此 pagagrapgh?
最佳答案
您声称要匹配段落中的单词。但是您的正则表达式仅匹配列表中至少两个 单词的序列(由于 {2,}
。这些单词可能由空格分隔,但也可能是一个接一个直接写,中间没有空格。如果你只想匹配单个单词,为什么不直接使用
[[:<:]](automobile|motor|roads|bycicle)[[:>:]]
关于Mysql 正则表达式 : match a list of words in a paragraph with regex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16434171/