使用正则表达式将字符串模式与一些示例自定义电子邮件域和某些例外相匹配?

时间:2018-09-12 07:13:21

标签: regex powershell

我正在构建一个正则表达式以捕获如下所示的字符串:

这些是我想要捕获或匹配的字符串:

https://southbeachfutons.in.net/css/upxx/?vfy!=IT.Admin@domain1.com
https://globosum.gb.net/js/0965/?qled!=Web.Admin@domain2.org
https://teandpaper.gb.net/img/654/?qled!=IT.Helpesk@domain1.net
https://babyforum.in.net/css/465/?apc1=Manager.DL@domain1.com

此字符串是安全的或不需要匹配(例外):

https://go.veeam.com/subscription-preferences.html?mkt_tok=mkaks444KMK2da472hwi3yuo5iufgshjkldfg76asd7gfd635423Bsda33nh8j8e312w34i987yt&DynamicEmail=Vong.Cin@domain1.net   

尝试了一下自己之后,我想到了:

query_set = Mymodel.objects.filter(name='Required').order_by('id')
values = query_set.values('id', 'field1', 'field2')
merged_values = merge_values(values)

但是,如果电子邮件地址长度超过25个字符并且该模式位于安全列表中,则会失败。

1 个答案:

答案 0 :(得分:0)

我有以下字符串:

[.^\/].{0,5}.\=[^=]+\@(?:domain1\.net|domain1\.com |(domain|domains)\.com)

适用于几行网址,但对于以下合法的电子邮件正文却以某种方式失败:

示例电子邮件正文1:

Account Summary ~ Amount calculated is based on the total sum of the savings or earnings on each of the products shown in the "My Offers" section of your Shopping Rewards online account. 
http://click.email.shoprewards.com/?qs=55893b3eff016662fbcb5131b282b9b40c4b7a2c7e21dafe299ae3 
Click here to see these offers.

 This is a system generated email sent to Dean.Lombardo@domain1.com. Please do not reply. You're receiving this email because you're a member of the Shopping Rewards loyalty program. Don't miss out on exclusive offers

示例电子邮件正文2:

  (42.6 /2= $21.30).

[cid:43CD7C39-DC53-4630-960C-A4D7FAAE918D]

That's for the salary per hour for the user Preeta.Akshay@Domains.com

电子邮件正文示例3:     邮件正文     网站:http://SAI.global.com/urlwrap/?q=AbVtLSw&Zwww.passengertransport.com

From:  <mailto:Danielle@passengertransport.com>Danielle@passengertransport.com < <mailto:Danielle@passengertransport.com>Danielle@passengertransport.com> 
Sent: Monday, 17 September 2018 11:11 AM
To: Cathy < <mailto:Cathy@domains.com> Cathy@domains.com>

那该如何解决呢?