tutor2000 Posted June 18, 2004 Share Posted June 18, 2004 I can parse for email address with filereadline, But how would I parse the emails if I have the text all read into a var already? Some emails would have spaces and some would end with illegal chars Rick Link to comment Share on other sites More sharing options...
pekster Posted June 18, 2004 Share Posted June 18, 2004 Depends on how you read it in. I'm assuming each line isn't a seperate element in an array, otherwise you could use the same technique you used for FileReadLine to run through a for loop on the array elements. How about searching for the occurance of an @ character, starting with the left-most side and working towards the right side. Once you find one, continue backing up towards the left until you hit the beginning of the string, or an illegal char (like a space, or whatever.) Do the same for the right. If you might have an @ character where there is no email address, you'll also want to have some kind of a VerifyEmail function, just to make sure no illegal chars are in the email itself (like two @'s, or something.) [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
tutor2000 Posted June 18, 2004 Author Share Posted June 18, 2004 Depends on how you read it in. I'm assuming each line isn't a seperate element in an array, otherwise you could use the same technique you used for FileReadLine to run through a for loop on the array elements. How about searching for the occurance of an @ character, starting with the left-most side and working towards the right side. Once you find one, continue backing up towards the left until you hit the beginning of the string, or an illegal char (like a space, or whatever.) Do the same for the right. If you might have an @ character where there is no email address, you'll also want to have some kind of a VerifyEmail function, just to make sure no illegal chars are in the email itself (like two @'s, or something.)great idea like a stringright starting with the first char then finding the @ and going to a function to get the email addy then moving onThanksRick Link to comment Share on other sites More sharing options...
pekster Posted June 18, 2004 Share Posted June 18, 2004 Instead of testing each character, why not use StringInStr to get the next position? Here is a template of what my idea was: Func FindEmails($input) ;localize all variables here since it's a func Local $return[1];I just localized my array for this example For $i = 1 To StringLen($input) $symbol = StringInStr($input, "@", 0, $i) If $symbol = 0 Then ExitLoop ;keep going backwards from the $symbol position until you hit a space ;also watch out for the start of $input, and stop if we reach that $start = <OUR_DISCOVERED_START_LOCATION> ;now go forwards from that $symbol position until you hit a space ;also watch out for the end of the $input, and stop if we reach that $end = <OUR_DISCOVERED_STOP_LOCATION> ReDim $return[$i];expand array as needed $return[$i-1] = StringMid($input, $start, $end-$start) Next return $return EndFunc [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
tutor2000 Posted June 19, 2004 Author Share Posted June 19, 2004 Instead of testing each character, why not use StringInStr to get the next position? Here is a template of what my idea was: Func FindEmails($input) ;localize all variables here since it's a func Local $return[1];I just localized my array for this example For $i = 1 To StringLen($input) $symbol = StringInStr($input, "@", 0, $i) If $symbol = 0 Then ExitLoop ;keep going backwards from the $symbol position until you hit a space ;also watch out for the start of $input, and stop if we reach that $start = <OUR_DISCOVERED_START_LOCATION> ;now go forwards from that $symbol position until you hit a space ;also watch out for the end of the $input, and stop if we reach that $end = <OUR_DISCOVERED_STOP_LOCATION> ReDim $return[$i];expand array as needed $return[$i-1] = StringMid($input, $start, $end-$start) Next return $return EndFuncLove ya mannnnnnnn Gotta study this one a bit. You guys are geniuses Rick Link to comment Share on other sites More sharing options...
Recommended Posts
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