Forums
This topic is locked
Use RegExp to remove an email address....
Posted 14 Feb 2011 19:14:31
1
has voted
14 Feb 2011 19:14:31 Dimitris Kouris posted:
Hi all,I was wondering if is possible to remove an email address that is included within a string (e.g from a textarea) using something like this:
Function isEmailValid(email)
Set regEx = New RegExp
regEx.Pattern = "[.\w]{3,}@[.\w]{5,}"
isEmailValid = regEx.Test(trim(email))
End Function
If so, how? Sample code?
Thanks
Dimitris
Replies
Replied 15 Feb 2011 11:12:43
15 Feb 2011 11:12:43 Patrick Woldberg replied:
just replace it with an empty string to remove, so when using your pattern
Function RemoveEmails(str) Dim re Set re = New RegExp re.Pattern = "[.\w]{3,}@[.\w]{5,}" re.Global = True RemoveEmails = re.Replace(str, "") Set re = Nothing End Function