[英]xml schema regex - how to select capital letter followed by all lowercase
So I have to following XML elements:所以我必须遵循 XML 元素:
<branch>
<branchName>Emperor</branchName>
</branch>
and和
<branch>
<branchName>Perception<branchName>
</branch>
.. and so on, all of which start with a capital letter and the rest is lowercase. .. 等等,所有这些都以大写字母开头,其余都是小写字母。 I tried to use Regex to capture this however this is my first time using it an I just throw together the following:我尝试使用 Regex 来捕获它,但是这是我第一次使用它,我只是将以下内容放在一起:
"[A-Z](([a-z])*)"
When I tried to validate my schema using the validator it did not work, I got an error saying:当我尝试使用验证器验证我的架构时,它不起作用,我收到一条错误消息:
ERROR - cvc-pattern-valid: Value 'Emperor' is not facet-valid with respect to pattern '[A-Z](([a-z])*)' for type '#AnonType_branchNamebranchbranches'.
ERROR - cvc-type.3.1.3: The value 'Emperor' of element 'branchName' is not valid.
ERROR - cvc-pattern-valid: Value 'Perception' is not facet-valid with respect to pattern '[A-Z](([a-z])*)' for type '#AnonType_branchNamebranchbranches'.
ERROR - cvc-type.3.1.3: The value 'Perception' of element 'branchName' is not valid.
Essentially I looked at w3schools version of how to restrict data.基本上我查看了如何限制数据的w3schools版本。 After that I looked around for a tutorial for regular expressions but none show how to combine expressions, they just show how you write individual parts.在那之后,我四处寻找正则表达式的教程,但没有展示如何组合表达式,它们只是展示了如何编写各个部分。
1) My question is how do I show this using a regular expression? 1)我的问题是如何使用正则表达式来显示? (An uppercase followed by n number of lower cases) (大写字母后跟 n 个小写字母)
2) could you direct me to a good tutorial that shows from start to end how to create a regular expression for xml 2)你能指导我一个很好的教程,从头到尾展示如何为 xml 创建正则表达式
(An answer to 1 is appreciated but only if 2 is also answered. I do want to learn this for myself) (对 1 的回答表示赞赏,但前提是也回答了 2。我确实想为自己学习这个)
edit 31/03/2016 @ 01:38: Changed the question in order to make what I was asking more clear.编辑 2016 年 3 月 31 日 @ 01:38:更改了问题以使我问的更清楚。
1) My question is how do I show this using a regular expression? 1)我的问题是如何使用正则表达式来显示? (An uppercase followed by n number of lower cases) (大写字母后跟 n 个小写字母)
Using regex like this.像这样使用正则表达式。
Regex: ^[AZ][az]+
.正则表达式: ^[AZ][az]+
。 If you use *
instead of +
it will also match is there are zero
lower case letters.如果您使用*
而不是+
它也将匹配zero
个小写字母。
您可以尝试使用 out ^ 它将匹配 aBc 也作为正确的字符串。
^[A-Z][a-z]+
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.