有没有人发现REGEX"\ b"在MYSQL中不起作用? [英] Has anyone found that REGEX "\b" doesn't work in MYSQL?

查看:55
本文介绍了有没有人发现REGEX"\ b"在MYSQL中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人发现REGEX"\ b"在MYSQL中不起作用吗?

Has anyone found that REGEX "\b" doesn't work in MYSQL?

我有一个很好的正则表达式,可以使用正则表达式引擎很好地匹配

I have a nice piece of regex that matches well using regex engines


^(//)?w7\b

但是当我将其用作MYSQL查询的一部分

But when I use it as part of a MYSQL query


WHERE ( e.department REGEXP '^(//)?w7\b' )

不匹配.如果我删除\ b组件,则匹配效果很好,但是与\ b所需的精度不符(基本上我只需要匹配整个单词W7)

it will not match. If I remove the \b component, the match works well but its not to the accuracy that I need with the \b (basicly I need to match the whole word W7 only)

谢谢!

推荐答案

查看

Look at the REGEXP docs, towards the bottom. The start-of-word/end-of-word markers are:

[[:<:]], [[:>:]]

这些标记代表单词边界.它们分别与单词的开头和结尾匹配.

These markers stand for word boundaries. They match the beginning and end of words, respectively.

尝试:

WHERE ( e.department REGEXP '^(//)?w7[[:>:]]' )

这篇关于有没有人发现REGEX"\ b"在MYSQL中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆