Link to home
Start Free TrialLog in
Avatar of ZURINET
ZURINET

asked on

Regular Expression to Validate Email Addresses

I am looking for regular expression . to use in a schema to validate valid e-mail addresses

Thanks in Advance

ZH
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium 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
Avatar of ZURINET
ZURINET

ASKER

Hi Gertone

Thanks for your help..
I just need to do some experiment.. :-)

Your solutions it just okay..

Just one more comment.. please

How can I represent  international and national phone number

 + 41 079 515 37 44
or  
00 41 079 515 37 44
or
00- 41 - 079 - 515 - 37- 44
or 079 515 37 44

I need to filter only these number formats with regular expression

I need to be able to accept numbers 0 - 9 including + and - signs

Thanks





This will do
<xs:simpleType name="tel-type-base">
    <xs:restriction base="xs:string">
        <xs:pattern value="[0-9+\-\s]+"></xs:pattern>
    </xs:restriction>
</xs:simpleType>

Open in new window

> but it will allow unvalid addresses such as abc..@def.com
That user does not seem to currently exist on def.com, but there is nothing inherently unvalid about that address.  You wouldn't want to have to change your regular expression every time def.com added or removed a user.
According to the email address RFC, a local part of an email address should not
- start with a dot
- end with a dot
- have two dots in a row
so that is inherently unvalid as far as I know
yep, I checked
http://www.ietf.org/rfc/rfc0822.txt?number=822
drill down the sequence
local-part > word > atom