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


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.


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

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

Answered By – Mat

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published