aspose file tools*
The moose likes Servlets and the fly likes Space checking in a String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Space checking in a String" Watch "Space checking in a String" New topic
Author

Space checking in a String

Brian
Greenhorn

Joined: Nov 22, 2004
Posts: 1
Is there a way to check for space inside a String value? I am validating email address in my application and need to make sure I have a some what valid email address.

Thanks
john guthrie
Ranch Hand

Joined: Aug 05, 2002
Posts: 124
i think this is in the wrong group, but String.indexOf is your answer
Salman Khattak
Ranch Hand

Joined: Mar 23, 2003
Posts: 33
i would use regular expressions to check valid email addresses.
regexlib.com has good regex


SCJP Java 1.4 - 06/2003<br />Power corrupts and absolute power corrupts absolutely!
Java Green
Greenhorn

Joined: Sep 07, 2004
Posts: 7
There is an implemetation provided in struts validator frame work to check whether it is email or not. There is an "isEmail()" method available in org.apache.commons.validator.GenericValidator class which is available in commons-validator.jar, can be downloadable from struts.apache.org
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Is there a way to check for space inside a String value? I am validating email address in my application and need to make sure I have a some what valid email address

Assuming we are talking about addresses for SMTP, valid SMTP email addresses can have spaces in them.

Also the class InternetAddress packaged with JavaMail will validate an address as part of its constructor, unless you tell it otherwise. So if you are eventually using the address to send mail, then this is a perhaps a more sensible route than including extra 3rd party dependancies.
[ November 23, 2004: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

"Brian"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

"Java Green"-
You have been asked 7 times already to adjust your displayed name to meet the

JavaRanch Naming Policy.

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Space checking in a String