我需要能够从ASP Classic中的字符串中提取电子邮件地址。
示例字符串为“有关查询详细信息,请从xxxx中的XXXX与Cp。联系-嗨,我写信给您取消谢谢。克里斯皮尔森(Chris Pearson)电子邮件地址:chris@itsanemail.com.au电话号码:07 56431545首选联系方式:“电子邮件” 结果是“ chris@itsanemail.com.au”
请注意,电子邮件不会始终位于字符串中的相同位置。但是,两侧总是会有空格。
我可以在excel中完成此操作,但是找不到脚本来执行此操作。它不一定是完美的。如果能赢得大多数人就很开心
答案 0 :(得分:2)
Function GetEmailAddrFromStr(TheString)
If InStr(1,TheString,"@") > 0 Then
TheAt = InStr(1,TheString,"@")
StartMarker = InstrRev(TheString, " ", TheAt, 0)
EndMarker = InStr(TheAt,TheString," ")
GetEmailAddrFromStr = Trim(Mid(TheString,StartMarker,EndMarker-StartMarker))
Else
GetEmailAddrFromStr = ""
End If
End Function
SomeText = "Hi, I am writing to you to cancel Thank you . Chris Pearson email address : chris@itsanemail.com.au phone number : 07 56431545 Preferred contact method : Email"
Response.write GetEmailAddrFromStr(SomeText)