You said:
Just tried /(\w*)@(\w*.)?uws.edu.au/ and that seemed to work. Any further suggestions are welcome – Jason 4 secs ago
Your regex will match "@teacher.uws.edu.au"
(i.e. "name portion" omitted).
To fix this, you could use:
/(\w+)@(\w+\.)?uws\.edu\.au/
Which will require at least one character in the name portion, and at least one char before the dot (if there is a dot) in the subdomain spot.
Also (I think) that \w
will not match .
(and probably other chars that you care about in the name portion too), so bob.jones@student.uws.edu.au
would fail to match. The following would add the char .
, _
, and -
into the "name" portion:
/([\w\._-]+)@(\w*\.)?uws\.edu\.au/
you could add any other chars you need in the same way.
NOTE: Matching email addresses in general a more complex thing than you might think (lots of strange things are technically allowed in email addresses. Here is an article on the subject (There are many other sources of similar information available).