有人可以解释一下REGEXP吗?

问题描述 投票:0回答:1

我是这个世界的新手。我目前正在做一些关于MariaDB约束的证明,可以检查每个空格后是否应该有一个大写字母(主要是检查名称的格式是否正确)。有人给了我下面的代码,但是我真的不明白(它可以正常工作,但是我需要有人向我解释一下Regexp的工作原理)。

CONSTRAINT nombreok CHECK (not (nombre_director collate latin1_general_cs) REGEXP '(^|[[:space:]])[[:lower:]]')
sql regex mariadb constraints regexp-like
1个回答
0
投票

正则表达式由组件组成:

此正则表达式匹配任何以小写字母开头或在空格字符后有小写字母的值。

这里是按组件分类的细分:

'(^|[[:space:]])[[:lower:]]'
-^ "(" a grouping is about to begin.
--^ "^" match the beginning of the string
---^ "|" --> or.  That is, match the beginning of the string or whatever is next
----^ "[" a set of matching characters
-----^ "[:space:]" these characters are space-like characters, such as spaces and tabes
--------------^ ")" grouping ends.  So the "group" identifies the beginning of the string or spaces
----------------^ "[" following the grouping is another set of characters
-----------------^ "[:lower:]" these characters are lowercase
© www.soinside.com 2019 - 2024. All rights reserved.