Validating a string which contains Numbers, Characters Or Space in Java

Hi,I need to validate a string which may contain Numbers Or Characters Or Space.Kindly help me.
[116 byte] By [Venkat09a] at [2007-11-27 3:42:52]
# 1

What's a character?

String test = " !a b 23455";

if (test.matches("\\p{Alnum}+")) {

System.out.println("Yes");

} else {

System.out.println("Yes");

}

Kaj

kajbja at 2007-7-12 8:46:29 > top of Java-index,Java Essentials,Java Programming...
# 2

I am not sure what you mean by validating in this case but here is a method that might help. In this example you use regular experssions to find a particular subString in a String.

Example:

String greatings = "Hello World! and Happy World!";

IsPattern("Happy", greatings);

where greatings "IsPattern" function is:

private boolean IsPattern(String aSearch, String aPropert) {

aSearch = aSearch.replaceAll("\\*", ".*");

Pattern patern = Pattern.compile(aSearch);

CharSequence input = aPropert;

Matcher match = patern.matcher(input);

return match.find();

}

The return value is true in this example.

I hope this helps.

BD.

BinaryDecimala at 2007-7-12 8:46:29 > top of Java-index,Java Essentials,Java Programming...