hi all i need help with vbs. i don't have any ideea about coding.
the script must to the next
- function to search email address in txt or html code
the clean these text and leave only the email address.
i need this script to insert it in one program.
I'd say that the best way to handle this would be using Regular Expressions.
If you'd like a more specific code related answer you might have to tell us exactly where the text to search is coming from and what exactly you want to do with the text you find. Actually extracting the e-mail address(es) from the text is probably one of the easier parts of this problem.
Regards
HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!
You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman
Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before post
Search for the @ character and you have the email address(es).
All you have to do is open the file, read a line from it, search the line for @, write the email address to another text file, close the files when done.
thanks all for reading my post but i already have the solution.
here it is.
Function Main(strHTMLText)
dim strSearchFor, nPos, strResult
Set RegularExpressionObject = New RegExp
With RegularExpressionObject
.Pattern = "([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})"
.IgnoreCase = True
.Global = True
End With
Set objMatches = RegularExpressionObject.Execute( strHTMLText )
strResult = " "
For Each objMatch in objMatches
strSearchFor = " "+objMatch.value + "; "
If ( InStr ( strResult, strSearchFor ) = 0 ) Then
strResult = strResult + objMatch.value + "; "
End If
Next
all of which are theoretically valid characters in the local part of an email address. The pattern presented looks to be a validator for Hotmail addresses, which do not allow all of the characters designated in the relevant RFC
Email addresses do not have spaces in them right? So if you search for @ and then find the space before and after the @ you will be able get the email address from the text.
sincerly i don't know what type of function i need to use..
my ideea is have a lot of link in my html code and i want to clean them all leaving only the linked text.
because in how i said i don't know what i use.
on this program wich i want to use i have a drop down box wich tell Java Script or VBScript....
so because i don't... i think for that
[tt][maroon]function main_2(strHTMLText) { //clean a-tag only
var RegularExpressionObject = new RegExp("<a[^>]*>([\\s\\S]*?)</a>","gi");
var strResult=strHTMLText.replace(RegularExpressionObject," $1 ");
return strResult
}
[/ignore]\">Google Link</a> to Google Link.";
alert (main_2(s));[/maroon]
[/tt]
But then you still need to know quite a bit on how it merges into a browser and event handling. Can't help with that distance in view.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.