Reputation: 2291
What would look regex for selecting every white space? I've tried to do few combinations, including excluding nums, digits etc but to no avail.
Upvotes: 9
Views: 24949
Reputation: 37299
\s is the best for a match to a white space character. White space here would be defined as [\t\n\f\r\p{Z}].
Try this link for C++ Regex: http://userguide.icu-project.org/strings/regexp
Upvotes: 1
Reputation: 10351
If the language/environment supports it, you can use the \s
modifier.
In perl:
$str = "my string that has spaces"
if($str =~ m/\s/)
{
#it has a white space character
}
If you cannot use \s
directly, you can combine all the items in the list here into one character class. From that link:
If ECMAScript-compliant behavior is specified, \s is equivalent to [\f\n\r\t\v]
Upvotes: 0
Reputation: 93026
What about a simple
\s+
together with a match_all method or option, depending on your language?
See it here online on Regexr, the good place to test regular expressions
Upvotes: 14