Skip to main content
edited body
Source Link
Zo72
  • 15.1k
  • 17
  • 73
  • 105

You should not use regular expressions to validate an input string to check if it's an email. It's too complicated and would not cover all the cases.

Now since you can only cover 90% of the cases, write something like:

function isPossiblyValidEmail(txt) {
   return txt.length > 05 && txt.indexOf('@')>0;
}

You can refine it. For instance, 'aaa@' is valid. But overall you get the gist. And don't get carried away... A simple 90% solution is better than 100% solution that does not work.

The world needs simpler code...

You should not use regular expressions to validate an input string to check if it's an email. It's too complicated and would not cover all the cases.

Now since you can only cover 90% of the cases, write something like:

function isPossiblyValidEmail(txt) {
   return txt.length > 0 && txt.indexOf('@')>0;
}

You can refine it. For instance, 'aaa@' is valid. But overall you get the gist. And don't get carried away... A simple 90% solution is better than 100% solution that does not work.

The world needs simpler code...

You should not use regular expressions to validate an input string to check if it's an email. It's too complicated and would not cover all the cases.

Now since you can only cover 90% of the cases, write something like:

function isPossiblyValidEmail(txt) {
   return txt.length > 5 && txt.indexOf('@')>0;
}

You can refine it. For instance, 'aaa@' is valid. But overall you get the gist. And don't get carried away... A simple 90% solution is better than 100% solution that does not work.

The world needs simpler code...

Copy edited. More affirmative answer. Removed meta information.
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 109
  • 132

You should not use reg-expregular expressions to validate an input string to check if it's an email. It's too complicated and would not cover all the cases.

Now since you can only cover 90% of the cases why not writing, write something like:

function isPossiblyValidEmail(txt) {
   return txt.length > 0 && txt.indexOf('@')>0;
}

You can refine it. For instance, 'aaa@' it'sis valid. but But overall you get the gist. andAnd don't get carried away... aA simple 90% solution is better than 100% solution that does not work.

Please add +1, theThe world needs simpler code...

You should not use reg-exp to validate an input string to check if it's an email. It's too complicated and would not cover all the cases.

Now since you can only cover 90% of the cases why not writing something like:

function isPossiblyValidEmail(txt) {
   return txt.length > 0 && txt.indexOf('@')>0;
}

You can refine it. For instance 'aaa@' it's valid. but overall you get the gist. and don't get carried away... a simple 90% solution is better than 100% solution that does not work.

Please add +1, the world needs simpler code...

You should not use regular expressions to validate an input string to check if it's an email. It's too complicated and would not cover all the cases.

Now since you can only cover 90% of the cases, write something like:

function isPossiblyValidEmail(txt) {
   return txt.length > 0 && txt.indexOf('@')>0;
}

You can refine it. For instance, 'aaa@' is valid. But overall you get the gist. And don't get carried away... A simple 90% solution is better than 100% solution that does not work.

The world needs simpler code...

Post Made Community Wiki by pera
added 52 characters in body
Source Link
Zo72
  • 15.1k
  • 17
  • 73
  • 105

You should not use reg-exp to validate an input string to check if it's an email. It's too complicated and would not cover all the cases.

Now since you can only cover 90% of the cases why not writing something like:

function isPossiblyValidEmail(txt) {
   return txt.length > 0 && txt.indexOf('@')>0;
}

You can refine it. For instance 'aaa@' it's valid. but overall you get the gist. and don't get carried away... a simple 90% solution is better than 100% solution that does not work.

Please add +1, the world needs simpler code...

You should not use reg-exp to validate an input string to check if it's an email. It's too complicated and would not cover all the cases.

Now since you can only cover 90% of the cases why not writing something like:

function isPossiblyValidEmail(txt) {
   return txt.length > 0 && txt.indexOf('@')>0;
}

You can refine it. For instance 'aaa@' it's valid. but overall you get the gist. and don't get carried away... a simple 90% solution is better than 100% solution that does not work.

You should not use reg-exp to validate an input string to check if it's an email. It's too complicated and would not cover all the cases.

Now since you can only cover 90% of the cases why not writing something like:

function isPossiblyValidEmail(txt) {
   return txt.length > 0 && txt.indexOf('@')>0;
}

You can refine it. For instance 'aaa@' it's valid. but overall you get the gist. and don't get carried away... a simple 90% solution is better than 100% solution that does not work.

Please add +1, the world needs simpler code...

added 66 characters in body
Source Link
Zo72
  • 15.1k
  • 17
  • 73
  • 105
Loading
Source Link
Zo72
  • 15.1k
  • 17
  • 73
  • 105
Loading