-1

I need to find a regular expression that validates an email address in the simplest form and the email address should not exceed 250 characters. Here is what I came up with so far.

(?=.{1,250}$)(.+)@(.+){2,}\.(.+){2,}

The problem is this expression works for small email lengths sets. i.e. If I put 10 instead of 250 it will work. If I tested the above expression against large sample it will throw catastrophic backtracking exception. https://regex101.com/r/Dv2j2U/1. Can someone please help me solving this?

rawel
  • 2,923
  • 21
  • 33

1 Answers1

3

Just replace (.+){2,} with .{2,}

Fallenhero
  • 1,563
  • 1
  • 8
  • 17
  • Thanks @Fallenhero for the effort. I was finally able to come up with expression with your help. Working expression for me is (?=^.{1,250}$)(.+)@.{2,}\..{2,} – rawel Feb 22 '17 at 00:35