我有一個文本,我想從“電子郵件:******”開始捕獲電子郵件
Details of Contact Made:
Sender's Name: Test (Individual)
Mobile: 4354354354
Email: [email protected]
Message: I am interested in your property. Please get in touch with me
Click here
<https://www.magicbricks.com/bricks/mailerautologin.html?
我試過了.match(/Email\:(.*)\1/g)
但我得到[Email:]的不是[email protected]
我如何從群組中獲得匹配的電子郵件
uj5u.com熱心網友回復:
您需要訪問第一個捕獲組。但我會使用這個版本:
var text = `Details of Contact Made:
Sender's Name: Test (Individual)
Mobile: 4354354354
Email: [email protected]
Message: I am interested in your property. Please get in touch with me
Click here
<https://www.magicbricks.com/bricks/mailerautologin.html?`;
var email = text.match(/Email:\s*(\S ?@\S )/)[1];
console.log(email);
uj5u.com熱心網友回復:
這個正則運算式將得到你想要的:
/(?<=Email: )(.*)/g
請檢查https://regexr.com/6tuln
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/507578.html
標籤:javascript 正则表达式
上一篇:如何僅洗掉表行的最后tds/列?
