Chea Indian Chea Indian - 5 months ago 9
Java Question

How do I check whether input string contains any spaces?

I have a input dialog that asks for XML element name, and I want to check it to see if it has any spaces.

can I do something like name.matches()?

Answer

Why use a regex?

name.contains(" ")

That should work just as well, and be faster.

Comments