So I have to following XML elements:
<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:
"[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. 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? (An uppercase followed by n number of lower cases)
2) could you direct me to a good tutorial that shows from start to end how to create a regular expression for xml
(An answer to 1 is appreciated but only if 2 is also answered. I do want to learn this for myself)
edit 31/03/2016 @ 01:38: Changed the question in order to make what I was asking more clear.
1) My question is how do I show this using a regular expression? (An uppercase followed by n number of lower cases)
Using regex like this.
Regex: ^[AZ][az]+
. If you use *
instead of +
it will also match is there are zero
lower case letters.
您可以尝试使用 out ^ 它将匹配 aBc 也作为正确的字符串。
^[A-Z][a-z]+
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.