-2

I found this regex as an email validation but i can't understand what is means, I tried to enter multiple forms of emails but they didn't work, I think there is a problem in this regex.

^[A-Z0-9][A-Z0-9._%+-]{0,63}@(?:[A-Z0-9]{1,63}.){1,125}[A-Z]{2,63}$

can anyone explain what is this regex means and give an example for it.

Thanks in advance.

Tasnim Zuhod
  • 103
  • 1
  • 2
  • 10
  • Is there a particular part of it that you don't understand? If not, this question is off topic as too broad. – Steven Doggart Feb 27 '16 at 13:21
  • 1
    [regex101](https://regex101.com/) is your friend. Anyway this is just another check for a (sort of) valid e-mail address. – Margaret Bloom Feb 27 '16 at 13:23
  • This definitely looks wrong, since email is not supposed to be such a big string of `63` or `125` characters. –  Feb 27 '16 at 13:28

3 Answers3

0

Are you using Php? I'd use this command instead

filter_var('bob@example.com', FILTER_VALIDATE_EMAIL);

However, the Regex you supplied has to meet a certain requirement on how the email looks

The first character has to be alphanumeric.

There is no options applied to this Regex, so as is, it will require the email to have all letters in uppercase

Josh S.
  • 602
  • 3
  • 8
0

Here is a good explanation of your regexp How to Find or Validate an Email Address

Andriy Kryvtsun
  • 2,766
  • 1
  • 22
  • 32
0

To start, all of the A-Z (which are only capital letters) are probably meant to be a-zA-Z.

^ and & are the beginning and end of the input.

[A-Z0-9][A-Z0-9._%+-]{0,63}

It then looks for any number between 0 and 63 of pairs of characters of which the first is a capital letter or a number, and the second any of thse: A-Z, 0-9, ., _, %, +, -.

@(?:[A-Z0-9]{1,63}.){1,125}

After that it looks for the character @ followed by 1 to 125 sets of characters that contain between 1 and 36 times A-Z or 0-9 and than any characters (. is probably meant to be \.).

[A-Z]{2,63}

At the end it looks for 2 to 63 times a character between A-Z.

"TEST@TT03SFD.TT" should work for this regex. This is really hard to put in words so I hope it makes some sense... I would use ^[a-zA-Z0-9._%+-]{1,63}@([a-zA-Z0-9]{1,53}\.){1,125}[a-zA-Z]{2,63}$ instead.

thijmen321
  • 463
  • 1
  • 3
  • 13