# wp_spaces_regexp()

URL: https://chugunov.pro/api-wordpress/functions/wp_spaces_regexp/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 4.0.0.

## Сигнатура

```php
wp_spaces_regexp(): string
```

## Описание

По умолчанию к пробелам относятся переводы строк, табуляции, entity-последовательности nbsp и UTF-8 nbsp.
Это предназначено для замены последовательности «s» в PCRE. В тикете #22692 выяснилось, что эта последовательность ненадёжна из-за случайного включения байта A0.

## Возвращаемое значение

`string`

## Исходный код

Файл: `wp-includes/formatting.php:5843`

```php
function wp_spaces_regexp() {
	static $spaces = '';

	if ( empty( $spaces ) ) {
		/**
		 * 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.
		 */
		$spaces = apply_filters( 'wp_spaces_regexp', '[\r\n\t ]|\xC2\xA0|&nbsp;' );
	}

	return $spaces;
}
```

## История изменений

- 4.0.0 — Introduced.

## Связанные

Использует: [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: [`wptexturize_primes`](https://chugunov.pro/api-wordpress/functions/wptexturize_primes/), [`wptexturize`](https://chugunov.pro/api-wordpress/functions/wptexturize/), [`shortcode_unautop`](https://chugunov.pro/api-wordpress/functions/shortcode_unautop/), [`smilies_init`](https://chugunov.pro/api-wordpress/functions/smilies_init/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/wp_spaces_regexp/
