Chea Indian Chea Indian - 1 year ago 53
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 Source

Why use a regex?

name.contains(" ")

That should work just as well, and be faster.