0

I just really need help with building a regex of this pattern XXX@XXX.XXX

Starts with at least 3 char not @
then @ (only one)
at least 3 char that are not . or @
and than one .
than 3 char that are not . or @

This is what I played with but it doesnt work

/^([a-zA-Z0-9._-]{3,})\.@([a-zA-Z0-9.-]{3,*})\.[a-zA-Z]{3,*}$/
Jerry
  • 70,495
  • 13
  • 100
  • 144
  • What characters are legal? Are you trying to match an email address? You might try searching first, as there are hundreds of questions like this. – crush Sep 13 '13 at 19:53
  • and if that's for validating email addresses, I can 99% guarantee that none of the answers are correct – Alnitak Sep 13 '13 at 19:55
  • 1
    At least keep your bad regex consistent! You put `{3,}` which is correct, but then later you put `{3,*}` twice... – Niet the Dark Absol Sep 13 '13 at 19:55
  • 1
    How does it not work? The regular expression you described is `/[^@]{3,}@[^@.]{3,}\.[^@.]{3}/` – FrankieTheKneeMan Sep 13 '13 at 19:55
  • possible duplicate of [Using a regular expression to validate an email address](http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address) – Jonathan Sep 13 '13 at 19:55

3 Answers3

2
^[^@]{3,}@[^@\.]{3,}\.[^@\.]{3}$

This is the regex you're looking for. But if you want to validate an e-mail address don't use this regex.

Adam Wolski
  • 5,448
  • 2
  • 27
  • 46
0

Try with

 /\b[^@]{3,}@[^.@]{3,}\.[^.@]{3}\b/

it should work. The \b means a token boundary.

davide
  • 1,918
  • 2
  • 20
  • 30
0
/^([^@]{3,})@([^.@]{3,})\.([^.@]{})$/

First block matches atleast 3 characters that are not @ Second is one @ Third is atleast 3 characters that are not . or @ Fourth is a . Fifth is 3 characters that are not . or @

Cjmarkham
  • 9,484
  • 5
  • 48
  • 81