wp_spaces_regexp

Filters the regexp for common whitespace characters.

Description

apply_filters( 'wp_spaces_regexp', (string) $r_n_t_xc2_xa0_nbsp ); 

This string is substituted for the \s sequence as needed in regular expressions. For websites not written in English, different characters may represent whitespace. For websites not encoded in UTF-8, the 0xC2 0xA0 sequence may not be in use.

Parameters (1)

0. $r_n_t_xc2_xa0_nbsp (string) => '[\r\n\t ]|\xC2\xA0| '
Regexp pattern for matching common whitespace characters.

Usage

To run the hook, copy the example below.
  1. $r_n_t_xc2_xa0_nbsp = apply_filters( 'wp_spaces_regexp', $r_n_t_xc2_xa0_nbsp ); 
  2.  
  3. if ( !empty( $r_n_t_xc2_xa0_nbsp ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the wp_spaces_regexp callback 
  2. function filter_wp_spaces_regexp( $r_n_t_xc2_xa0_nbsp ) { 
  3. // make filter magic happen here... 
  4. return $r_n_t_xc2_xa0_nbsp
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'wp_spaces_regexp', 'filter_wp_spaces_regexp', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'wp_spaces_regexp', 'filter_wp_spaces_regexp', 10, 1 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/formatting.php  
  1. $spaces = apply_filters( 'wp_spaces_regexp', '[\r\n\t ]|\xC2\xA0| ' );