I made an XML Schema and I have this in it.

```
<xs:element name="Email">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:pattern value="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>

```

Some of my emails in one of my XML documents fail and I get this error

> 
> Email' element is invalid - The value
>  'Some\_Name@hotmail.com' is invalid
>  according to its datatype 'String' -
>  The Pattern constraint failed.
>  LineNumber: 15404 LinePostion: 32
> 
> 
> 

So just looking at all the emails that passed and the ones that failed I noticed that all the ones that failed have an "\_(underscore)". So I am unsure if this is the reason or not.

Edit

So I changed my regex to this

```
 <xs:pattern value="[\w_]+([-+.'][\w_]+)*@[\w_]+([-.][\w_]+)*\.[\w_]+([-.][\w_]+)*"/>

```

It now works but don't understand why `\w` is not capturing it.