google hired ben!
So will there be a google browser again?
The future of the web. The health of the web.
Update 2007-09-01: read the official mozilla enterprise wiki for more information about enterprise deployment of firefox.
Labels: firefox
God!
They did this, Mac mini, they did this, iPod shuffle.
This is...I can not find a word. They changed the world again.
Labels: apple
I have been looking for a javascript email regexp email validator. And I found one from this web site. And the code is
"/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i"
This code looks nice.
However, I am not totally satisfied with the code. Because there are emails addresses don't look like "abc@abc.com". For example, I used to send email to an address like "joel@192.168.100.1". So I am going to make some change to the regular expression filter.
Update 1:
"/^([\w-]+(?:\.[\w-]+)*)\@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$|(\[?(\d{1,3}\.){3}\d{1,3}\]?)$/i"
will detect email like "abc@127.0.0.1" or "abc@[127.0.0.1]".
Update 2:
/^([\w-]+(?:\.[\w-]+)*)\@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$|(\[?(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\]?)$/i
Now this one won't let a.b.c@256.0.0.0 slip.
Update 3:
/^(("?)[\w- ]+\1)|([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$|(\[?(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\]?)$/i
Now this regular expression thinks "Guy Joel"@abc.com or "Guy Joel"guyj@abc.com are good email address.
Update 4:
/^(("?)[\w-\s]+\1)|([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$|(\[?(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\]?)$/i
A little bit more update on space in the regexp.
Update 5:
/^("[\w-\s]+")?([\w-]+(?:\.[\w-]+)*)?@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$|(\[?(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\]?)$/i
Made a big mistake in the last one. So, another update.
Update 6:
/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$|(\[?((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\]?)$/i
It's getting longer and longer, better and better.
Update 7:
/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i
The update 6 thinks 256.255.255.255 is a legal ip address, fixed in update 7.
string | result |
joel@joel.com | pass |
joel@joel.edu | pass |
joel@joel.museum | pass |
joel@joel.ac.uk | pass |
joel@guy.joel.ac.uk | pass |
guy.joel@guy.joel.ac.uk | pass |
guy.joel@127.0.0.1 | pass |
guy.joel@[127.0.0.1] | pass |
\"Guy Joel\"guy.joel@[127.0.0.1 | pass |
\"Guy Joel\"@[127.0.0.1] | pass |
\"Guy Joel\"@9.999.99.25 | fail |
\"Guy Joel\"@999.99.99.25 | fail |
"\"Guy Joel\"" | fail |
Also, regular expression for url validation.
Labels: email, javascript, regexp, regular expression
Nowadays web developers do browser side form input check by javascript and server side form input check. Although without browser side form input check everything will be OK, we'd better do it. Because we can save some computing power on the server side. If a web user input some thing wrong, the server application need to check for mistakes, generate a page explain the error, and then the server need to check the input and process the data again.
If we have browser side form input check, the error check process will be done on the browser side computer.
But if we can do form input check at the browser side, why do we need check it again at server side? Because there are hackers, there are bad people. They can do whatever to put something wrong onto the server, to crash the application, to mess up our database. So we need to check the input on the server side again.
However, most of the input will be done by good customers, so with the help of browser side form input check, the server side form input check need only work onece, rather than twice or more.