XSD string pattern independent of leading/trailing space
        Posted  
        
            by AndiDog
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by AndiDog
        
        
        
        Published on 2010-05-11T14:02:28Z
        Indexed on 
            2010/05/11
            14:34 UTC
        
        
        Read the original article
        Hit count: 313
        
I have a XSD simple type that should match UUIDs:
<simpleType name="UuidT">
    <restriction base="string">
        <pattern value="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}" />
    </restriction>
</simpleType>
It correctly matches the following content:
<!-- valid -->
<Uuid>12345678-1234-5678-9012-123456789012</Uuid>
But it doesn't match content that contains excess whitespace:
<!-- not valid -->
<Uuid>
    2de25a81-b117-4b2a-b910-50f0878884f7
</Uuid>
Sure, I could add \s* to both sides of the regex, but isn't there a simpler solution in XSD?
© Stack Overflow or respective owner