如何在MySQL中使用regex ?

时间:2021-08-25 19:29:05

I want to filter out those with field not like '%_[0-9]+' ,

我想过滤掉那些不像'%_[0-9]+'的字段,

but it turns out that MySQL doesn't take it as regex,

但MySQL并不把它当做regex,

is that possible in MySQL?

这在MySQL中可能吗?

1 个解决方案

#1


17  

That happens because of LIKE is not supposed to accept regular expression as a parameter. There is REGEXP for such things

这是因为LIKE不应该接受正则表达式作为参数。这样的东西有REGEXP

WHERE field NOT REGEXP '%_[0-9]+'

#1


17  

That happens because of LIKE is not supposed to accept regular expression as a parameter. There is REGEXP for such things

这是因为LIKE不应该接受正则表达式作为参数。这样的东西有REGEXP

WHERE field NOT REGEXP '%_[0-9]+'