Comments (9)
Though the date pattern is matching on 30/02/2016 for me
Except that feb. 30th doesn't exist 😉
Regarding the HTML tag pattern, that's pretty useful for plain text HTML, like in an editor.
Except that there are a gazillion ways the regex will match incorrectly (demonstrated here) or cause trouble otherwise. Have you read the stackoverflow answer I linked to?
PRs are very welcome if you want to make any improvements yourself.
All the ones I pointed out are very case-specific and hard, if not impossible (html, email for example), to get correct. Though I can think of improvements here-and-there I'd suggest taking them all down; for most, if not all, of the regexes there are better ways of handling and validating the inputs (like simply parsing a date(time) value to 'validate' it or sending an activation e-mail to verify an e-mail address).
Regexes do have their use, I'm not saying they don't. But, as said, for most (if not all) of the examples there are much better solutions.
Edit: Here's more I just stumbled upon.
from regexhub.
Thanks @RobThree some valid points there.
Though the date pattern is matching on 30/02/2016 for me.
Regarding the HTML tag pattern, that's pretty useful for plain text HTML, like in an editor.
I've now removed the password pattern as that was proving particularly controversial.
PRs are very welcome if you want to make any improvements yourself.
from regexhub.
Regarding the HTML tag pattern, that's pretty useful for plain text HTML, like in an editor.
<b>this html</b><b>would beg the differ</b>
from regexhub.
Re: Emails. The only true way to validate emails is with basic pattern matching. Something along the lines of looking for @.* is the most you can possibly hope to do.
I completely agree with Rob on that point.
from regexhub.
@CSobol email pattern has now been updated with this PR: #15
from regexhub.
It also lacks a ^ and $ for the time pattern, just like the date one, otherwise it matches "4;30" when you input "24:00"
from regexhub.
I seem to run into a bug with the pattern document.body.innerHTML=flags//whoops
;)
from regexhub.
For the email, several regex can help to filter some bad formats.
Lot of sites are still expecting 'simple' emails, eg. max 3 chars for TLD (.com)!
The question is to know if you want a valid one or one that will work on almost on all sites.
Few filters
Maximum length: 254 due to network protocols, not email specs, search RFC...
Minimum length: 7 like [email protected]
.{7,254}
Rough validation of min/max length blocks:
.{1,248}@.{2,250}\..{2,64}
Enhancing this formula, the 3 lengths, is ?impossible? in regex as you need to know the length of each part, must use javascript, not just regex.
Just for Latin char set, supposing case insensitive is set (/..../i):
[a-z][a-z0-9\._-]{0,246}[a-z0-9]@[a-z][a-z0-9\._-]{0,248}[a-z0-9]\.[a-z][a-z0-9\.]{0,61}[a-z]
(Should verify the above one)
A bit more international, but invalid characters are not filtered (spacesss, tabsss, I think controls are except DEL):
[!-\uFFEF]{1,248}@[!-\uFFEF]{2,250}\.[!-\uFFEF]{2,64}
64 is the maximum, today the maximum existing is 24
XN--VERMGENSBERATUNG-PWB
http://data.iana.org/TLD/tlds-alpha-by-domain.txt
Few links
To test your suppositions:
http://cobisi.com/support/kb/emailverify.net/verification-process/validation-levels
Free Mailgun.com validation api, not just the syntax:
https://www.mailgun.com/email-validation
Explanation of unicode in regex:
http://www.regular-expressions.info/unicode.html
For the lazy one, this one is from a framework, dont remember which one...
But mailgun is ok.
Apparently it respects all the rules, except it does not check the length, see above.
function is_valid_email_address(email_address) { var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_
{|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(.([a-z]|\d|[!#$%&'*+-/=?^_{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
from regexhub.
The question is to know if you want a valid one or one that will work on almost on all sites.
That's an easy answer. When it comes to email addresses, you never want to stop a valid user from signing up via email address. You would much rather take a hundred junk email address than prevent one valid user from signing up or filling out a form.
from regexhub.
Related Issues (12)
- The RegEx for HTML tags does not match the HTML Headings tags HOT 1
- Password regex limitations HOT 3
- Regex for dollar or currency amounts HOT 3
- Maybe some integration with regex101.com would be nice?
- Regex for IP Range
- Date regex doesn't validate dates < 1900 || > 2099 HOT 2
- Integrate with RegexHQ HOT 2
- The RegEx for 'Time in 24-hour format' does not give minutes value in the output
- how to deploy locally/
- Time in 24-hour format
- Youtube Check for HTTP too HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from regexhub.