简体   繁体   English

正则表达式:电子邮件地址中的多个子域

[英]Regular expression: multiple subdomain in email address

It wasn't hard to find everything between the @ character, but the problem is that I need every word before the .不难找到@字符之间的所有内容,但问题是我需要. (dot) character. (点)字符。

If the email, for example, is: studentname@student.studentschool.com , then I need to have the every word after the @ character and before every .例如,如果电子邮件是: studentname@student.studentschool.com ,那么我需要在@字符之后和每个. (dot). (点)。

student  
studentschool

What I tried so far only works for one domain.到目前为止我尝试过的仅适用于一个域。

(?<=@)[A-Za-z]{2,40}

Can't figure it out.想不通

Easy!简单! Try this:尝试这个:

([^.@]+)\.

Demo: https://regex101.com/r/nM4jV7/2演示: https : //regex101.com/r/nM4jV7/2

Explanation:解释:

Get everything that's just before a dot, but doesn't consist @ .获取点之前的所有内容,但不包含@ Then capture the string in a group, excluding the ending dot.然后在一个组中捕获字符串,不包括结尾点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM