Mysql 正则表达式 : match a list of words in a paragraph with regex

标签 mysql regex

我有一段是这样的:

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/

相关文章:

regex - Perl 就地编辑搞乱了文本编码

php - 匹配单词,然后匹配潜在的括号字符串,然后匹配潜在的方括号字符串

java - JPA 中实体的序列生成器

mysql - 如果不存在则创建表返回 "the table doesn´t exist"

php - Laravel 不获取 MySQL 登录信息

C++ 模板和字符串文字

mysql - 如何正确执行触发器?

c++ - 使用 mysql C API 准备语句的 C++ 中的堆栈损坏警告

regex - 使用 r 从字符串中提取电子邮件地址

java - 如何用正则表达式替换java程序中的xml标签和值