이메일은 항상 최종 <>
에 동봉되어있는 경우 수
Public Function fmt(email As String) As String
pos = InStrRev(email, "<")
If (pos > 0) Then
email = Mid$(email, 1 + pos, 1 + Len(email) - pos)
email = Left$(email, Len(email) - 1)
End If
fmt = email
End Function
또는
replace(mid(email,instrrev(email,"<")+1,len(email)),">","")
편집;
정규식 검사의 경우 "Microsoft VBScript 정규식 라이브러리"(tools> references)에 대한 참조를 추가하고;
Public Function fmt(email As String) As String
pos = InStrRev(email, "<")
If (pos > 0) Then
email = Mid$(email, 1 + pos, 1 + Len(email) - pos)
email = Left$(email, Len(email) - 1)
End If
fmt = email
With New RegExp
.Global = True
.IgnoreCase = True
.MultiLine = True
.Pattern = "^\[email protected]\S+\.\S+$"
If Not .Test(fmt) Then fmt = ""
End With
End Function
유효하지 않은 이메일 주소 또는 올바른 이메일 주소를 반환합니다.
RE를 삭제했습니다. 추론 : Using a regular expression to validate an email address
후기 바인딩은 참조를 만드는 것보다 우수합니다. –
@David : 글쎄요, 개발에 따라 초기 바인딩은 라이브러리의 객체 모델을 마음에두고 잘 모르는 숙련되지 않은 개발자에게 많은 도움이됩니다 (IntelliSense 등). 물론 배포를 위해 런타임에 바인딩으로 전환하면 많은 문제를 방지 할 수 있습니다. – Heinzi
나는 내 물건을 쉽고 안정적으로 만들어야한다. 때로는 개발자로서 더 열심히 노력해야한다는 의미입니다. –