Has anyone found that REGEX "\b" doesn't work in 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

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!


Solution 1:

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.