Results 1 to 2 of 2
- 03-08-2012, 08:59 PM #1
Check if a string contains whitespace characters
I want to make a check that find if a string only contains whitespace characters.
I added this: "String".matches("\\s")
This work as long as the strings length is equal to 1. If the string contains two or more spaces(or a tabb space), it will fail.
Edit: Never mind. I found a way, by calling string.trim () and then string.isEmpty ().
Last edited by Pojahn_M; 03-08-2012 at 09:10 PM.
- 03-08-2012, 10:16 PM #2Senior Member
- Join Date
- Oct 2010
- Rep Power
- By roud9 in forum New To JavaReplies: 4Last Post: 11-05-2010, 11:43 AM
- By alacn in forum New To JavaReplies: 8Last Post: 07-07-2010, 12:52 PM
- By j_kathiresan in forum New To JavaReplies: 1Last Post: 04-30-2010, 03:21 PM
- By Somitesh Chakraborty in forum New To JavaReplies: 3Last Post: 08-20-2008, 08:56 PM
- By Alayna in forum New To JavaReplies: 2Last Post: 05-20-2007, 11:49 AM