0

I just really need help with building a regex of this pattern [email protected]

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,*}$/
5
  • 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. Commented Sep 13, 2013 at 19:53
  • and if that's for validating email addresses, I can 99% guarantee that none of the answers are correct Commented Sep 13, 2013 at 19:55
  • 1
    At least keep your bad regex consistent! You put {3,} which is correct, but then later you put {3,*} twice... Commented Sep 13, 2013 at 19:55
  • 1
    How does it not work? The regular expression you described is /[^@]{3,}@[^@.]{3,}\.[^@.]{3}/ Commented Sep 13, 2013 at 19:55
  • possible duplicate of Using a regular expression to validate an email address Commented Sep 13, 2013 at 19:55

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

6 Comments

This is the regex he described, but I think it is very unlikely it is the one he is looking for.
true ;-) Validating e-mail with this regex is not proper
@AdamWolski, You are missing the ^...$, otherwise we could have /[^@]{3,}@[^@\.]{3,}\.[^@\.]{3}/.test('@[email protected]'); //true
According to his description, this can be valid. Note, that he didn't say that it should validate an e-mail address.
But, according to his attempt (he used ^ and $) you're right ;)
|
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 @

Comments

0

Try with

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.