wp_spaces_regexp

函式
wp_spaces_regexp ( No parameters )
返回值
  • (string) The spaces regexp.
定義位置
相關方法
wp_cache_resetwp_safe_remote_getwp_cache_getwp_safe_remote_postwp_safe_redirect
引入
4.0.0
棄用
-

wp_spaces_regexp: 該函式用於匹配正規表示式模式中的空格。它用於匹配字串中的空格,例如,將一個字串分割成單詞,或查詢一個單詞在字串中的位置。

返回常見的空白字元的反義詞。

預設情況下,空格包括新行、製表符、nbsp實體和UTF-8的nbsp。 這是為了取代PCRE的序列。在 ticket #22692 中,由於隨機包含 A0 位元組,該序列被發現是不可靠的。

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', '[rnt ]|xC2xA0| ' );
	}

	return $spaces;
}

常見問題

FAQs
檢視更多 >