aspose file tools
The moose likes HTML, CSS and JavaScript and the fly likes function to check spaces between a word Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "function to check spaces between a word" Watch "function to check spaces between a word" New topic
Author

function to check spaces between a word

Latha Kota
Ranch Hand

Joined: Mar 13, 2003
Posts: 35
I have a page in whic user enters values and submits the form. I want to know if there is any function to check if the user enters spaces in between the word. If anybody knows how to do it please let me know.
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50673

Well that's obviously too specific a function to already be part of the String class, but all the tools you need are right there in the String class to write your own.
You can either search for an instance of the space character (if all you are interested in is whether the string has a space or not), loop through the characters of the string looking for the space character (if you need to count them or some such), or you can use a regular expression if you are looking to detect patterns that are a little more complex than that.
Why not try writing up your own version of a method "doesStringHaveSpaces()" and if you have any difficulties with it, post your code and you'll be sure to get some help with it. Don't expect anyone to write the code for you though; that's not the purpose of this site.
hth,
bear
[ April 04, 2003: Message edited by: Bear Bibeault ]

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
 
subject: function to check spaces between a word
 
Threads others viewed
while loop
jsp and javascript!!
what is this doing?
Javascript - alert dialog box and text box
formating outFile
MyEclipse, The Clear Choice