1

I recently found following pattern definition that defines a GUID:

<xs:pattern value="\{[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\}"/>

I need some help to understand this. Here are my problems:

/ not at the ending, at the begin of the value attribute.
- between the letter definition(ex:[a-fA-F0-9]).

It's not explained at the w3 site.

Community
  • 1
  • 1

1 Answers1

0

Point 1:

/ not at the ending, at the begin of the value attribute.

The only / in the xs:pattern you show is part of the XML syntax for a empty-element tag. This is a normal XML construct unrelated to the pattern being defined for a GUID; it could equivalently have been written with an explicit closing tag:

<xs:pattern value="..."></xs:pattern>

Point 2:

- between the letter definition(ex:[a-fA-F0-9]).

The - in [] signifies a range in regular expressions. So, [a-f] allows all letters from a to f, inclusive. The entire [a-fA-F0-9] allows all hexadecimal digits.

Some other points you didn't ask about:

  • The \{ or \} means that a literal { or } is expected.
  • The {8} means that 8 of the preceding subpattern (hex digits) are expected.
  • The - outside of [] means that a literal - is expected.

So, together, this pattern is matching GUIDs wrapped in { }, e.g:

{90B1532C-3611-48D8-BBAB-D44855FA73BD}
kjhughes
  • 106,133
  • 27
  • 181
  • 240
  • I tried to ask for point 1 and 3 of your aditional points ;) But thank iam understanding the pattern defintion now... –  Apr 22 '16 at 12:04