douketangyouzh5219 2010-11-05 04:16
浏览 25
已采纳

如何验证此表格的电子邮件地址:234903284@student.uws.edu.au

I'd like to know a regex that would validate: an email address to this form: 234903284@student.uws.edu.au

couple issues:

"student." is optional and could be any word eg "teacher.".

"324234234" can be any alpha numeric characters (number, word, _ etc.)

the email must end in "uws.edu.au"

This is what I have so far:

/(\d*)@\w*\.uws\.edu\.au/

valid addresses:

me@uws.edu.au 234234324@student.uws.edu.au theking@teacher.uws.edu.au

etc.

Thanks Guys

  • 写回答

2条回答 默认 最新

  • duansaoguan7955 2010-11-05 04:36
    关注

    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).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?