Views regex: exclude alphabetical strings as well as those with spaces I used the following regular expression on the Taxonomy term name field to exclude strings consisting solely of alphabetical names:

[^a-zA-Z]

Now I want to exclude those strings plus any string with a space.

What I want to do:


Hello (no)
Hi how are you (no)
ハロー (ok)


I tried this:

[^a-zA-Z\s]

This excludes alphabetical strings but not alphabetical strings with a space:


Hello (no)
Hi how are you (yes-> should be no)
ハロー(ok)


What am I doing wrong?
The Views module uses MySQL regular expressions, and \s is not recognized in those regular expressions.

You should try with [^a-zA-Z[:blank:]], or [^a-zA-Z[:space:]]. The first excludes any whitespace character, while the second excludes any space, tab, newline, and carriage return.

In the views_handler_filter_string class, the method associated with the regular expression is the following one.

  function op_regex($field) {
    $this-&gt;query-&gt;add_where($this-&gt;options['group'], $field, $this-&gt;value, 'RLIKE');
  }




// Add regexp support for MySQL.
if (Database::getConnection()-&gt;databaseType() == 'mysql') {
  $operators += array(
    'regular_expression' =&gt; array(
      'title' =&gt; t('Regular expression'), 
      'short' =&gt; t('regex'), 
      'method' =&gt; 'op_regex', 
      'values' =&gt; 1,
    ),
  );
}