这是我的声明,但我只是抱怨意外的REGEXP SELECT * FROM `Officers` WHERE `fullName` REGEXP '.*\sJ.*'; MariaDB中有什么方法可以做到这一点,不幸的是,名称不是固定的字数,有些只是2个名称,其他是6个名称,所以只有4个中间名称.解决方案您可以使用REGEXP '\\bJ' ^^^在这里,\b是一个单词边界,仅当J前面没有字母,数字或_时才会强制匹配. \被加倍,因为正则表达式引擎期望使用文字\,并且需要两个反斜杠.I'm having a problem a dataset I have been given in bad format E.G fullName column and no breakdown of names I'm wanting to search where any of the names start with a given letter E.G 'J'So this is my Statement but I just get complaints about unexpected REGEXPSELECT * FROM `Officers` WHERE `fullName` REGEXP '.*\sJ.*';Is there any way to do this in MariaDB, unfortunately, the names are not of a fixed word count some are only 2 names others are 6 names long so 4 middle names. 解决方案 You may useREGEXP '\\bJ' ^^^Here, the \b is a word boundary that will force a match only when J is not preceded with a letter, digit or _.The \ is doubled because the regex engine expects a literal \, and two backslashes are required. 这篇关于在线正则表达式测试器中运行的MariaDB正则表达式在SELECT WHERE REGEXP中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-25 02:15