Returns the regexp for common whitespace characters.
Description
By default, spaces include new lines, tabs, nbsp entities, and the UTF-8 nbsp.This is designed to replace the PCRE s sequence. In ticket #22692, that sequence was found to be unreliable due to random inclusion of the A0 byte.
Return
string
The spaces regexp.
Hooks fired · 1
One hook fires while wp_spaces_regexp() runs, in this order:
smilies_init()Converts smiley code to the icon graphic file equivalent.
wptexturize()Replaces common plain text characters with formatted entities.
wptexturize_primes()Implements a logic tree to determine whether or not "7'." represents seven feet, then converts the special char into either a prime char or a closing quote char.
5852functionwp_spaces_regexp(){5853static$spaces='';58545855if(empty($spaces)){5856/**5857 * Filters the regexp for common whitespace characters.5858 *5859 * This string is substituted for the \s sequence as needed in regular5860 * expressions. For websites not written in English, different characters5861 * may represent whitespace. For websites not encoded in UTF-8, the 0xC2 0xA05862 * sequence may not be in use.5863 *5864 * @since 4.0.05865 *5866 * @param string $spaces Regexp pattern for matching common whitespace characters.5867 */5868$spaces=apply_filters('wp_spaces_regexp','[\r\n\t ]|\xC2\xA0| ');5869}58705871return$spaces;5872}
History
Introduced in 4.0.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-includes/formatting.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.