Is there something wrong with my regex?

I made an XML Schema, and I have it 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 posts in one of my XML documents fail and I get this error

Element

Email is invalid - the value " Some_Name@hotmail.com " is invalid according to its data type "String" - Template restriction failed. LineNumber: 15404 LinePostion: 32

So, just looking at all the letters sent and those that failed, I noticed that all those who failed, "_ (underline)". Therefore, I am not sure if this is the reason or not.

Edit

So, I changed my regex to

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

Now it works, but does not understand why it \wdoes not capture it.

+3
5

W3C \w :

[#X0000-#x10FFFF]-[\p{P}\p{Z}\p{C}] ( , < "," "" ") *

Unicode - "LOW LINE" (U + 005F), : , [Pc]

XML Schema Unicode.

ASCII, [0-9A-Za-z_-] intead of \w ( , nonlatin :)), regexp RFC,

+6

- , \w . _ \w, _, [\w_].

+1

, .

:

, , .

0

. . ...

\w+([-+.'_]\w+)*...
0

- ; \w , Rubular, . , , - ? , , ; . , / .

0

Source: https://habr.com/ru/post/1757233/


All Articles