I want to know if a String such as “equi-distant” or “they’re” contains a non-word character. Is there a simple way to check for it?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends entirely on what you mean by “word character”.
If by “word character” you mean A-Z or a-z then you can use this:
If you mean “any character that is considered to be a letter in Unicode”, then look at
Character.isLetterinstead.This is code provided by bobbymcr nearly works:
However see the documentation:
This should work for all Unicode characters: