I am getting some articles and posts, which suggest that using regular expressions to validate user data Please. I am not sure of all things, but I get it usually in the case of email address verification.
So I have to make it clear that it is good to use regular expression to validate user input or not? If this is good, then what's wrong with this to validate the email address?
EDIT:
We can say that we can use regex for the basic primary recognition of the data type and for this good and complete verification we will call it the second parser There is a need to combine with
And for general verification, we can use it for the second part of the email verification but this is not appropriate according to the standard. Is this?
This is good because you can use regular expressions of an easy way To express and test complex patterns from
This is bad because regular expression can be complicated and you can do much wrong. Edit OK, okay here are some real advice: first make sure the expected valid value can be expressed using regular expressions. That happens when the language of the valid values is one, otherwise you can not use regular expressions (or at least not just regular expressions)!
Now that we know that using regular expression can be validated, then what is necessary to verify with the use of regular expressions, if we have an e-mail as an example Let's take an address (as many others do), we should know how anyone can look (see RFC 5322):
addr-spec = local -part "@" Domain local-part = dot-atom / cited-string / ob-local-part d Men = dot-atom / domain-Limitel / Obs-domain-written words = [Sifdblyues] "[" * ([Fdblyues] Dtext) [Fdblyues] "]" [Sifdblyues] Ditekst =% D33-90 /; Printable US-ASCII% d94-126 /; The characters do not include obs-dtext; "[", "]", Or "\"
Here we see that can be quoted in local-part Any printable US-ASCII character ( \ ). So it is not enough to check that there is only one and "", but can include @ ) in the string @ in the e-mail address, if we want to allow the address according to RFC 5322.
On the other hand, if we want to allow any legitimate e-mail address according to RFC 5322, we also allow those addresses which are probably not present or in most cases only fools (Like "localhost" ).
Comments
Post a Comment