sqwk/laravel — comment on commit 823f311a379fccf487539cc1ac3336fb56ca6ec7
File:  line 0
By sparksp:

It should be noted that `\s` is "any whitespace character" not just spaces. If you want to add just spaces simply include a space in the character class. See: [PHP: Escape Sequences](http://php.net/manual/en/regexp.reference.escape.php)

Also note, when including a `-` in a character class it should always be the last (or first) character, otherwise it indicates a range. I don't think in this case that it would range between `_` and `\s`, but for clarity and consistency it's best to keep the dash until last.

Having said all that, I'm not sure I'd want a space in these rules. They would no longer do what they say "on the tin".

Perhaps we could add some new string rules like...

```
function validate_word($attribute, $value)
{
// A "word" character is any letter or digit or the underscore character, that is,
// any character which can be part of a Perl "word". The definition of letters
// and digits is controlled by PCRE's character tables, and may vary if locale-
// specific matching is taking place. For example, in the "fr" (French) locale,
// some character codes greater than 128 are used for accented letters, and
// these are matched by \w.
return preg_match('/^\w+$/', $value);
}

function validate_words($attribute, $value)
{
return preg_match('/^[\w ]+$/', $value);
}
```