Sign in to follow this  
Followers 0
tutor2000

parsing for email addresses

5 posts in this topic

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


Only $2.00 with Resale Rights How to Block Better for Martial Artists and NonMartial Artistshttp://kirkhamsebooks.com/MartialArts/Bloc...tterEbook_m.htm

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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 on

Thanks

Rick


Only $2.00 with Resale Rights How to Block Better for Martial Artists and NonMartial Artistshttp://kirkhamsebooks.com/MartialArts/Bloc...tterEbook_m.htm

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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
Love ya mannnnnnnn

Gotta study this one a bit. You guys are geniuses

Rick


Only $2.00 with Resale Rights How to Block Better for Martial Artists and NonMartial Artistshttp://kirkhamsebooks.com/MartialArts/Bloc...tterEbook_m.htm

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0