Definitive XML Schema
Priscilla Walmsley (pwalmsley@datypic.com)
ISBN: 0130655678
1st edition, , Prentice Hall PTR.
Chapter 10: Regular expressions
Book examples
<xsd:simpleType name="ProdNumType"> <xsd:restriction base="xsd:string"> <xsd:pattern value="\d{3}-[A-Z]{2}|\d{7}"/> </xsd:restriction> </xsd:simpleType>
Regular expression | Matching strings | Non-matching strings |
---|---|---|
a
|
a
|
b
|
a|b|c
|
a, b, c
|
abc
|
Regular expression | Matching strings | Non-matching strings |
---|---|---|
a z
|
a z
|
az
|
a *z
|
az, a z, a z, a z
|
a *z
|
PB&J
|
PB&J
|
PBJ
|
Regular expression | Matching strings | Non-matching strings |
---|---|---|
1+2
|
12, 112, 1112
|
1+2
|
1\+2
|
1+2
|
12, 1\+2
|
1\++2
|
1+2, 1++2, 1+++2
|
12
|
Regular expression | Matching strings | Non-matching strings |
---|---|---|
a\dz
|
a0z, a1z
|
az, adz, a12z
|
a.z
|
a1z, axz
|
az, axxz
|
Regular expression | Matching strings | Non-matching strings |
---|---|---|
\p{Lu}
|
A, B, C
|
a, b, c, 1, 2, 3
|
\P{Lu}
|
a, b, c, 1, 2, 3
|
A, B, C
|
\p{Nd}
|
1, 2, 3
|
a, b, c, A, B, C
|
\P{Nd}
|
a, b, c, A, B, C
|
1, 2, 3
|
Regular expression | Matching strings | Non-matching strings |
---|---|---|
\p{IsBasicLatin}
|
a, b, c
|
â, ß, ç
|
\P{IsBasicLatin}
|
â, ß, ç
|
a, b, c
|
Regular expression | Matching strings | Non-matching strings |
---|---|---|
[abc]z
|
az, bz, cz
|
abz, z, abcz, abc
|
[\p{Lu}\d]z
|
Az, Bz, 1z, 2z
|
az, bz, cz, A1z
|
Regular expression | Matching strings | Non-matching strings |
---|---|---|
[a-f]z
|
az, fz
|
z, abz, gz, hz
|
[0-9a-fA-F]z
|
1z, az, Bz
|
z, gz, Gz, 1aBz
|
[ -]z
|
az, bz, cz
|
âz
|
Regular expression | Matching strings | Non-matching strings |
---|---|---|
[0-9pqr]z
|
1z, 2z, pz, rz
|
cz,dz, 0sz
|
[p-r\d]z
|
1z, 2z, pz, rz
|
cz,dz, 0sz
|
Regular expression | Matching strings | Non-matching strings |
---|---|---|
[^ab]z
|
cz, dz, 1z
|
az, bz
|
[^\d]z
|
az, bz, cz
|
1z, 2z, 3z
|
[^1-3a-c]z
|
dz, 4z
|
1z, az
|
Regular expression | Matching strings | Non-matching strings |
---|---|---|
[a-z-[c]]z
|
az, dz, ez, zz
|
cz
|
[a-z-[cd]]z
|
az, ez, zz
|
cz, dz
|
[a-z-[c-e]]z
|
az, zz
|
cz, dz, ez, 1z
|
[^a-z-[123]]z
|
4z
|
az, 3z, zz
|
Regular expression | Matching strings | Non-matching strings |
---|---|---|
(a|b)z
|
az, bz
|
abz, z
|
(ab)*z
|
z, abz, ababz
|
az, bz, aabbz
|
(a+b)*z
|
z, abz, aabz, abaabz
|
az, abbz
|
([a-f]x)*z
|
z, axz, bxfxfxz
|
gxz, xz
|
(\db)*z
|
z, 1bz, 1b2bz
|
1z, bz
|
Regular expression | Matching strings | Non-matching strings |
---|---|---|
abz
|
abz
|
az, abbz
|
ab?z
|
az, abz
|
abbz
|
ab*z
|
az, abz, abbz, abbbz
|
a1z
|
ab+z
|
abz, abbz, abbbz
|
az
|
ab{2}z
|
abbz
|
abz, abbbz
|
ab{2,}z
|
abbz, abbbz, abbbbz
|
az, abz
|
ab{2,3}z
|
abbz, abbbz
|
az, abz, abbbbz
|
a[b-d]+z
|
abz, abdz, addbccdddz
|
az, aez, abez
|
a\p{Nd}+z
|
a1z, a11z, a234z
|
az, abcz
|
a(bc)+z
|
abcz, abcbcz, abcbcbcz
|
az, abz
|