/    Sign up×
Community /Pin to ProfileBookmark

regex for url & email ??

Hello forums!!
I need a very good validation for “url” and “email” using regular expression.
Following are the criteria for url:
* may have http or https @ start
*
may or may not have www.
* may or may not have query string like ?action=a&pack=p
*
may also support for country level domain

Following are the criteria for email:
* [email][email protected][/email]
*
[email][email protected][/email]
* [email][email protected][/email]
*
[email][email protected][/email]
* may support above formats
Note: regex syntax should be valid for both php and javascript
Any suggestions, comments are warlmy welcome
Thanks in advance to all..

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@mojtabaAug 10.2007 — Hello dear,

For Email use this code...
[code=php] if(!preg_match("/^[.A-z0-9_-]+[@][A-z0-9_-]+([.][A-z0-9_-]+)+[A-z]{2,4}$/i", $Email))
print("Incorrect Email Address!");
[/code]


Bye.
×

Success!

Help @PHPycho spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...