如何从“文本/纯文本”类型的邮件正文中提取包含新行和特殊字符的字符串?

时间:2019-06-04 07:46:32

标签: python regex

如何从“文本/纯文本”类型的邮件正文中提取包含新行和特殊字符的字符串?

基本上,我需要阅读粗体中包含OTP的邮件。我可以将邮件正文作为字符串获取。但是无法从中提取OTP,因为它包含其他字符串,也包含换行符

Hi,

 Your new One Time Password is *123456*. Please use this OTP to
proceed with registration of or login to your account.


For any queries, contact us at support@abcd.com
subject=Help%20with%20Email%20Verification>```


This is the regex pattern that I'm using:

```matches = re.search(r"^Your new One Time Password is *[0-9]{6,6}* Please use this OTP to proceed$", body, re.DOTALL)```

0 个答案:

没有答案