Mysql regex error #1139 using literal -

别等时光非礼了梦想. 提交于 2019-12-02 05:32:57

Just change the order.

SELECT column FROM table WHERE column REGEXP '[^-A-Za-z\']'
chris85

@Avinash Raj is correct the - must be first (or last). The \ is not an escape character in POSIX, which is what mysql uses, https://dev.mysql.com/doc/refman/5.1/en/regexp.html.

One key syntactic difference is that the backslash is NOT a metacharacter in a POSIX bracket expression.

-http://www.regular-expressions.info/posixbrackets.html

What special characters must be escaped in regular expressions?

Inside character classes, the backslash is a literal character in POSIX regular expressions. You cannot use it to escape anything. You have to use "clever placement" if you want to include character class metacharacters as literals. Put the ^ anywhere except at the start, the ] at the start, and the - at the start or the end of the character class to match these literally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!