-1

Got another question. I have this assignment I need to do and I thought I understood what to do, but turns out I don't. So far I have this:

([a-z0-9][-a-z0-9_\+\.]*[a-z0-9])@([a-z0-9][-a-z0-9\.]*[a-z0-9]\.(com|net|org)

Every time I run the php code I get an error (I have the php tags at the start and end of the code just didn't include them). What I need to know is how to display this correctly so I can actually test what I'm supposed to be testing. For reference, this is what I am actually supposed to do.

Design a regular expression pattern that accepts email address

"jsmith456@test.com", "mjones@study.net", and "jane.doe@example.org"

but does not accept "john.smith@php.test", "john.jones@php.invalid", and "alan.smithee@test".

Test it with a script.

nico43624
  • 29
  • 6
  • 1
    What is your php code and what error do you get? – revo Apr 16 '18 at 21:13
  • Does it HAVE to be with regex? Possible duplicate of: https://stackoverflow.com/a/12026863/8837781 (see bottom of answer for REGEX, be sure to reed the NOTE) – Joas Apr 16 '18 at 21:19
  • only com net org??? and all the rest ? –  Apr 16 '18 at 21:26

1 Answers1

1

I would like to recommend a Regex online debugger like regex101; it explain part by part your regex code, and what is the function of each part. Also you're missing the ) that closes the parentheses of @(:

                                missing the closing parentheses of this.
                                  |
([a-z0-9][-a-z0-9_\+\.]*[a-z0-9])@([a-z0-9][-a-z0-9\.]*[a-z0-9]\.(com|net|org)
Julian David
  • 311
  • 1
  • 12