Filter hook 'wp_spaces_regexp'

in WP Core File wp-includes/formatting.php at line 5848

View Source

wp_spaces_regexp

Filter Hook
Description
Filters the regexp for common whitespace characters. 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.

Hook Information

File Location wp-includes/formatting.php View on GitHub
Hook Type Filter
Line Number 5848

Hook Parameters

Type Name Description
string $spaces Regexp pattern for matching common whitespace characters.

Usage Examples

Basic Usage
<?php
// Hook into wp_spaces_regexp
add_filter('wp_spaces_regexp', 'my_custom_filter', 10, 1);

function my_custom_filter($spaces) {
    // Your custom filtering logic here
    return $spaces;
}

Source Code Context

wp-includes/formatting.php:5848 - How this hook is used in WordPress core
<?php
5843  		 *
5844  		 * @since 4.0.0
5845  		 *
5846  		 * @param string $spaces Regexp pattern for matching common whitespace characters.
5847  		 */
5848  		$spaces = apply_filters( 'wp_spaces_regexp', '[\r\n\t ]|\xC2\xA0|&nbsp;' );
5849  	}
5850  
5851  	return $spaces;
5852  }
5853  

PHP Documentation

<?php
/**
		 * Filters the regexp for common whitespace characters.
		 *
		 * 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.
		 *
		 * @since 4.0.0
		 *
		 * @param string $spaces Regexp pattern for matching common whitespace characters.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/formatting.php
Related Hooks

Related hooks will be displayed here in future updates.