Link to home
Start Free TrialLog in
Avatar of j055
j055

asked on

regEx pattern validates differently in XML schema

Hi

This Regular expression doesn't accept underscores in a XML schema but it does validate with other tools. It's actually from ASP.NET.

\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

e.g. 'bill_smith@email.co.uk' fails.

It seems odd that a schema treats it differently. What do I need to do?

Thanks
Andrew
Avatar of ddrudik
ddrudik
Flag of United States of America image

Different apps/languages support regular expressions to varying degrees, if it's the \w in your expression that is the issue you could try:
[A-Za-z0-9_]+([-+.'][A-Za-z0-9_]+)*@[A-Za-z0-9_]+([-.][A-Za-z0-9_]+)*\.[A-Za-z0-9_]+([-.][A-Za-z0-9_]+)*

Open in new window

Avatar of j055
j055

ASKER

Thanks for the clues

I changes this:
\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
to this
\w+([-+.'_]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

I just needed to allow underscores before the @ sign.

Thanks
Andrew
ASKER CERTIFIED SOLUTION
Avatar of SyfAldeen
SyfAldeen
Flag of Egypt image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial