问题描述
我想使用正则表达式来过滤纯中文名称:
SELECT `name` FROM `table` WHERE `name` REGEXP '[u4e00-u9fa5]';
但是,根据此,这是不可能的,因此,我想从相反的方向来处理,查找没有任何字母,数字和特殊字符的内容(我知道它并不严格),但是找不到和"运算符,那么该怎么做呢?
MariaDB使用以10.0.5版本开头的 PCRE 正则表达式库:" 从MariaDB 10.0.5开始,MariaDB切换到PCRE正则表达式库以获取增强的正则表达式. ". >
要匹配包含中文字母的条目,请使用
REGEXP '[\\x{4e00}-\\x{9fa5}]'
甚至
REGEXP '\\p{Han}'
要匹配反义词,不带中文字母的条目,请使用:
REGEXP '^[^\\x{4e00}-\\x{9fa5}]*$'
或
REGEXP '^\\P{Han}*$'
I want to use regular expression to filter out pure Chinese name by this:
SELECT `name` FROM `table` WHERE `name` REGEXP '[u4e00-u9fa5]';
But, according to this, it isn't possible,so I want to approach that from opposite direction,find content without any letter,digital and special character(I knew that it is not rigid),but can't find "and" operator,so how to do it?
MariaDB uses PCRE regex library beginning with 10.0.5 version: "Starting with MariaDB 10.0.5, MariaDB switched to the PCRE regular expression library for enhanced regular expressions.".
To match entries that contain Chinese letters use
REGEXP '[\\x{4e00}-\\x{9fa5}]'
or even
REGEXP '\\p{Han}'
To match the reverse, entries with no Chinese letters, use:
REGEXP '^[^\\x{4e00}-\\x{9fa5}]*$'
or
REGEXP '^\\P{Han}*$'
这篇关于如何使用正则表达式匹配没有任何字母,数字或特殊字符的单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!