Raybaudi Posted September 9, 2005 Posted September 9, 2005 Hi all friends I tried to make a CF (recursive) to grab all the eMails from a given text ... but for now I do not got ! I thinked to count the words and so on... but the "@" character is considered a delimiter of words (as comment kindly explained to me). So I stopped ! The same CF can grab all the words with a given string inside them. Kind of: GetWords(text;string) PS: I can't find a similar CF in the brilliant Brian site
comment Posted September 9, 2005 Posted September 9, 2005 I don't see what difference it makes if "@" is a word delimiter or not. The question is how are your addresses separated from each other and from the rest of the text. FWIW, Ray has a scripted e-mail extractor on his site, which you could adapt to a CF, but I have to warn you that it fails at perfectly valid addresses.
Raybaudi Posted September 11, 2005 Author Posted September 11, 2005 Hi, I solved my problem with this recursive custom function that grab all the emails from a given generic text: GetEmail ( text ) custom function /* Author Daniele Raybaudi */ Let([ count = PatternCount ( text ; "@" ); len = Length ( Text ); pos = Position ( Text ; "@" ; 1 ; 1 ); ante@ = RightWords ( Middle (Text ;1 ;pos ) ; 1 ); post@ = LeftWords ( Middle (Text ; pos ; len ) ; 1 ); nextText = Middle ( text ; pos + 1 ; len ) ]; Case( count ; ante@ & "@" & post@ & "¶" & GetEmail ( nextText ); "" ) )
Raybaudi Posted September 11, 2005 Author Posted September 11, 2005 Hi comment there is a great difference! If "@" is a delimiter of words, I can easily get the left side and the right side of it with RightWords and LeftWords , as I did !
comment Posted September 11, 2005 Posted September 11, 2005 I'd suggest you check out some references on what is a valid e-mail address, then see if your CF extracts all possible variations. See for example: http://www.ietf.org/rfc/rfc0822.txt http://www.developer.com/lang/php/article.php/3290141 http://www.webreference.com/js/tips/000310.html
Raybaudi Posted September 11, 2005 Author Posted September 11, 2005 ok so my CF is, for now, good only for the most usually emails, NOT FOR ALL ! Thanks to comment. BTW I'm reading that looongs links... and I'll search to implement all the possibilities !
Raybaudi Posted September 11, 2005 Author Posted September 11, 2005 Hi this works for all the emails ! /* Author Daniele Raybaudi */ Let([ adjustedText = Substitute ( text ; "¶" ; " " ); count = PatternCount ( adjustedText ; "@" ); len = Length ( adjustedText ); pos = Position ( adjustedText ; "@" ; 1 ; 1 ); startWord = Position ( adjustedText ; " " ; pos ; -1 ) + 1; endWord = If ( Position ( adjustedText ; " " ; pos ; 1 ) ≠ 0 ; Position ( adjustedText ; " " ; pos ; 1 ) ; len + 1 ); word = Middle ( adjustedText ; startWord ; endWord - startWord ); nextText = Middle (adjustedText ; endWord + 1 ; len ) ]; Case( count ; word & "¶" & GetEmail ( nextText ); "" ) )
Raybaudi Posted September 11, 2005 Author Posted September 11, 2005 And this works for all the words that contains a given string. GetWords(text;string) /* Author Daniele Raybaudi modified 09/13/2005 */ Consenti([ adjustedText = CercaeSost ( text ; ["¶";" "]; [",";" "]; [".";" "]; [":";" "]; [";";" "]; ["!";" "]; ["?";" "]; [""";" "]; ["(";" "]; [")";" "]; ["%";" "]; ["/";" "]; ["*";" "]; ["-";" "]; ["[";" "]; ["]";" "]; ["'";" "]; ["£";" "]; ["$";" "]; ["&";" "]; ["=";" "]; ["^";" "]; ["+";" "]; ["§";" "]; ["°";" "]; ["#";" "]; ["_";" "]; ["<";" "]; [">";" "]; ["";" "]); count = ContaRicorrenze ( adjustedText ; string ); len = Lunghezza ( adjustedText ); pos = Posizione ( adjustedText ; string ; 1 ; 1 ); startWord = Posizione ( adjustedText ; " " ; pos ; -1 ) + 1; endWord = If ( Posizione ( adjustedText ; " " ; pos ; 1 ) ≠ 0 ; Posizione ( adjustedText ; " " ; pos ; 1 ) ; len + 1 ); word = Mezzo ( adjustedText ; startWord ; endWord - startWord ); nextText = Mezzo (adjustedText ; endWord + 1 ; len ) ]; Casi( count ; word & "¶" & GetWords ( nextText;string ); "" ) )
Recommended Posts
This topic is 7013 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now