MajorGeeks Support Forums

Go Back   MajorGeeks Support Forums > ----------= PC, Desktop and Laptop Support =---------- > Software
Register FAQ Members List Calendar Casino Mark Forums Read

Software Software such as operating systems like Windows XP, Windows Vista, Windows 7 etc., or specific programs.


Closed Thread
 
Thread Tools Display Modes
  #1  
Old 10-23-07, 20:37
JustAnotherDude's Avatar
JustAnotherDude JustAnotherDude is offline
Private First Class
 
Join Date: Oct 2007
Location: Massachusetts
Posts: 63
Thanks: 2
Thanked 3 Times in 3 Posts
Default Parsing strings - best method?

If a user enters more than one email address in a form field, what's best way to only allow the first one?

I thought about using explode, but the code I came up with seems rather inefficient, because the user may enter the data with "comma" between the addresses, or with "semicolon" between the addresses, and with or without whitespace between the addresses.

Suggestions greatly appreciated.
Thanks!
Sponsored links
  #2  
Old 10-24-07, 18:56
noahawk's Avatar
noahawk noahawk is offline
Corporal
 
Join Date: Aug 2004
Location: Pennsylvania
Posts: 285
Thanks: 0
Thanked 4 Times in 4 Posts
Default Re: Parsing strings - best method?

I'm thinking maybe accept the input and then look to see where the first space, comma, semicolon, etc. occurs and then take the substring from the beginning until just before that spot?
  #3  
Old 10-24-07, 19:32
JustAnotherDude's Avatar
JustAnotherDude JustAnotherDude is offline
Private First Class
 
Join Date: Oct 2007
Location: Massachusetts
Posts: 63
Thanks: 2
Thanked 3 Times in 3 Posts
Default Re: Parsing strings - best method?

Thanks for your response.
What you suggest is pretty much what I'm doing, except it takes me 4 lines of code (I've barely scratched the surface of PHP, so have a LOT to learn yet). Was thinking there's probably a better way.
  #4  
Old 10-27-07, 13:39
noahawk's Avatar
noahawk noahawk is offline
Corporal
 
Join Date: Aug 2004
Location: Pennsylvania
Posts: 285
Thanks: 0
Thanked 4 Times in 4 Posts
Default Re: Parsing strings - best method?

I don't know of any other way, but that doesn't mean there isn't. You could use dropdown boxes for the .com,.net,.org, but now with the proliferation of top level domains with email addresses, it may be hard to keep the list updated. But that is a surefire way to limit them to one address.
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving strings as csv files in VB6 ceal21c Software 2 05-25-06 20:48
VBA Strings BMD Software 2 01-19-06 14:55
vb6 Saving Strings and Integers mastermosley Software 15 10-26-05 21:42
Symantec Multiple Products UPX Parsing Engine Buffer Overflow NICK ADSL UK Virus Software Updates (Read Only) 0 02-10-05 16:31


All times are GMT -5. The time now is 00:49.

MajorGeeks.Com Menu

MajorGeeks.Com \ All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ NEW! PC Games \ System Tools \ Macintosh \ Demonews.Com \ Top Downloads

MajorGeeks.Com \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds


All content Copyright MajorGeeks.com source code Powered by vBulletin® Version 3.8.4
Copyright © 2009 vBulletin Solutions, Inc. All rights reserved.
Ad Management by RedTyger