我在使用正则表达式从数据库中获取数据时遇到了问题。当我在标签中搜索“man”时,它会返回包含“woman”的标签,因为它是子字符串。
SELECT '#hellowomanclothing' REGEXP '^(.)*[^wo]man(.)*$'; # returns 0 correct, it contains 'woman'
SELECT '#helloowmanclothing' REGEXP '^(.)*[^wo]man(.)*$'; # returns 0 incorrect, it can contain anything other than 'woman'
SELECT '#stylemanclothing' REGEXP '^(.)*[^wo]man(.)*$'; # returns 1 correct
当我搜索“man”时,如何更新正则表达式,使其仅返回包含“man”而不是“woman”的标签?
(.)*
(这没有意义),而是直接写.*
。 - Casimir et Hippolyte