Already a member? Log in

Sign up with your...

or

Sign Up with your email address

Add Tags

Duplicate Tags

Rename Tags

Share It With Others!

Save Link

Sign in

Sign Up with your email address

Sign up

By clicking the button, you agree to the Terms & Conditions.

Forgot Password?

Please enter your username below and press the send button.
A password reset link will be sent to you.

If you are unable to access the email address originally associated with your Delicious account, we recommend creating a new account.

ADVERTISEMENT
ADVERTISEMENT

Links 1 through 7 of 7 by Ho John Lee tagged regex

"Wanted to find a regular expression to validate e-mail addresses, but when I searched I found dozens of slightly different versions of the same expression. Almost all of them had people leaving comments about how it failed to validate or invalidate some rare but completely valid/invalid address syntax. ... So, I setup arrays of some of the most promising expressions as well as a (hopefully) complete sampling of valid and invalid addresses. It's my philosophy that it's better to accept a few invalid addresses than reject any valid ones, so I'm shooting for 0 false-positives and as few false-negatives as possible.

Conclusion:
James Watts and Francisco Jose Martin Moreno are the first to develop one which passes all of the tests.
/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i "

Share It With Others!

Discussion and commentary on approaches to building a regex for matching URLs

Share It With Others!

A common programming problem: identify the URLs in an arbitrary string of text, where by “arbitrary” let’s agree we mean something unstructured such as an email message or a tweet. I offer a solution, in the form of the following regex pattern:

\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))

This pattern should work in most modern regex implementations. I can vouch for it working in Perl, Ruby, and with the PCRE regex library (which in turn means it works in PHP and BBEdit, both of which use PCRE).

This pattern attempts to be practical. It makes no attempt to parse URLs according to any official specification. It isn’t limited to predefined URL protocols. It should be clever about things like parentheses and trailing punctuation.

Share It With Others!

Share It With Others!

Share It With Others!

Sed expressions are powerful, but somewhat obscure and easy to screw up. A handy cheat sheet for common tasks.

Share It With Others!

Build regular expressions using a GUI. Helpful if you can't remember the right punctuation marks, like me.

Share It With Others!

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT