-4

I have no experience with regular expressions in java script, but I need to derive a pattern for FMLast1234@ung.edu. There only needs to be a pattern for FMLast1234 because @ung.edu needs to remain the same. I am not sure if I just do this \b[a-z][a-z][a-z][0-9] or what. Does there need to be a range for each character in the pattern? I need to check for variations of the pattern FMLast1234 not just a random assortment of characters and numbers.

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
Inquirer
  • 7
  • 6
  • Do you explicitely want to check for variations of that specific format `FMLast1234` or you just want to allow any mix of alphanumeric characters? – plalx Oct 29 '13 at 14:32
  • I need to check for variations of that specific format. F stands for first letter of first name M is is first letter of middle name and last is first four of last name and then an id number. – Inquirer Oct 29 '13 at 15:06

1 Answers1

0
/[a-zA-Z0-9]@ung.edu/.test("123@ung.edu")  or  

if(emailString.split('@')[1] === "ung.edu")

Edit : As per plalx comment here is my answer

 /^\w+@ung.edu$/.test("aaa123@ung.edu")
Exception
  • 8,111
  • 22
  • 85
  • 136
  • You should always specify the *start* and *end* of such patterns. Otherwise something like `"#$~@3@ung.edu"` would match. – plalx Oct 29 '13 at 14:40