MajorGeeks Support Forums IOBit Software

Go Back   MajorGeeks Support Forums > Majorgeeks.Com - Support Forums > Programming
Register FAQ Members List Calendar Casino Mark Forums Read

Programming Place to discuss programming including HTML, Java, C++, MySQL and others.


Reply
 
Thread Tools Display Modes
  #1  
Old 10-23-07, 19: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!
Reply With Quote
Sponsored links
  #2  
Old 10-24-07, 17:56
noahawk's Avatar
noahawk noahawk is offline
Corporal
 
Join Date: Aug 2004
Location: Pennsylvania
Posts: 285
Thanks: 0
Thanked 2 Times in 2 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?
Reply With Quote
  #3  
Old 10-24-07, 18: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.
Reply With Quote
  #4  
Old 10-27-07, 12:39
noahawk's Avatar
noahawk noahawk is offline
Corporal
 
Join Date: Aug 2004
Location: Pennsylvania
Posts: 285
Thanks: 0
Thanked 2 Times in 2 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.
Reply With Quote
Reply

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 Programming 2 05-25-06 19:48
VBA Strings BMD Programming 2 01-19-06 13:55
vb6 Saving Strings and Integers mastermosley Programming 15 10-26-05 20:42
Symantec Multiple Products UPX Parsing Engine Buffer Overflow NICK ADSL UK Virus Software Updates (Read Only) 0 02-10-05 15:31
Bending Strings BluesMan Interesting Website Links 4 07-30-04 02:23


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


MajorGeeks.Com Home Page
| Admin Tools | All In One | Anti-Spyware | Anti-Virus | Appearance | Backup | Benchmarking | BIOS | Browsers | Covert Ops |
Data Recovery | Diagnostics | Drive Cleaners | Drive Utilities | Drivers | Driver Tools Ergonomics | Firewalls | Games | Game Tweaks | Graphics | Input Devices | Internet Tools | Macintosh | Mail Utilities | Memory | Messaging | Monitoring | Microsoft | Multimedia | Networking | Office Tools | Process Management | Processor | Registry | Security | System Info | Toys | Video | Miscellaneous
|

-->
Powered by vBulletin® Version 3.8.4
Copyright © 2009 vBulletin Solutions, Inc. All rights reserved.
Ad Management by RedTyger