开发者

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

Has any开发者_StackOverflowone found that REGEX "\b" doesn't work in MYSQL?

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

^(//)?w7\b

But when I use it as part of a MYSQL query

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

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)

Thank you!


For MySQL versions prior to MySQL 8.0.4, the REGEXP (MySQL 5.6 ref) docs indicate that the start-of-word/end-of-word markers are:

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

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

Try:

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

After 8.0.4, \b is used for word boundary instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜