java - Regex for university emails -
I'm making sure that they are a specific university subdomain, looking to validate email addresses, e.g. If the user says that they go to Oxford University, then I want to know that their email ends in .ox.ac.uk.
If I have '.ox.ac.uk' stored as a part variable, can I confirm that the whole email is valid and that variable ends in suffix?
Many thanks!
We are using this email pattern (received from):
^ [\ w! # $% & Amp; '* + / =? ^ `{|} ~ -]: | - * @ ((\ [\ w # $% & amp; * '+ / = ^' {} ~]?.??): [One-zA-Z0-9] ([a-zA-Z0-9 - ] * [One-zA-Z0-9]?) \ [+ Z- $ ` You should be able to expand it with your required suffix:
^ [\ w # $% & amp; '* + / = ^ `{|} ~ - + (?.!: \ [\ W # $% & amp;],'? * + / =` {|} ~ -]) * @ - \) + ((: [A-zA-Z0-9] ([one-zA-Z0-9] * [one-zA-Z0-9]?):?. \ .x \ .ac \ .uk) $ ` Note that I changed the TLD part [a-zA-Z0- 9] (?: [A-zA-Z0-9 -] * [a-zA] -Z0- 9])? (? Ox. .c \ .uk) (. with its required suffix to match only dot ) Editing: An additional note: If you type string # matches (...) or Matcher # matches () , Then the key ^ is not required and the following is $, why That is why the entire string must match anyway.
Comments
Post a Comment