已关闭。此问题需要details or clarity。当前不接受答案。
**想要改进此问题吗?**通过editing this post添加详细信息并阐明问题。
17小时前就关门了。
Improve this question
我已经写了一个自动化脚本发送OTP电子邮件。我已经存储在一个字符串列表的电子邮件。下面是代码:
public static void main(String[] args) throws FileNotFoundException, Exception{
EmailUtils emailUtils = new EmailUtils();
Properties prop = new Properties();
prop.load(new FileInputStream("/Users//Automation/Automation/src/main/java/Resources/config-email-otp.properties"));
Store connection = emailUtils.connectToGmail(prop);
emailUtils.getUnreadMessages(connection, "Inbox");
List<String> emailtext = emailUtils.getUnreadMessageByFromEmail(connection, "Inbox", "no-reply@xxxx.in", "Email ID verification");
现在,我想从电子邮件中提取OTP。
通过电子邮件发送它在控制台中的显示方式:
This is the message envelope
---------------------------
FROM: dummyemail@gmail.com
TO: dummyemail@gmail.com
SUBJECT: Email ID verification
----------------------------
CONTENT-TYPE: TEXT/HTML; charset=us-ascii
This is a string
---------------------------
<!doctype html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.t.org">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Email verification</title>
</head>
<body>
<div>Dear User,</div>
<div>You are performing account verification operation , the verification code is: <b>4740</b></div>
<div>This verification code can only be used once, and it will automatically become invalid after verification.</div>
<div>(Please complete the verification within 30 minutes, the verification code will become invalid after 30 minutes, you need to verify again.)</div>
<div>Please ignore this email if we send the wrong address, thanks.</div>
<div>team</div>
</body>
</html>
1条答案
按热度按时间mspsb9vt1#
您需要群组1的值。如果只使用\d{4},您也会符合w3.org的年份。x1c 0d1x
完整示例: