_get_wptexturize_split_regex

Retrieve the combined regular expression for HTML and shortcodes.

Description

(string) _get_wptexturize_split_regex( (string) $shortcode_regex = '' ); 

Returns (string)

The regular expression

Parameters (1)

0. $shortcode_regex — Optional. (string) => ''
The result from _get_wptexturize_shortcode_regex(). Optional.

Usage

  1. if ( !function_exists( '_get_wptexturize_split_regex' ) ) { 
  2. require_once ABSPATH . WPINC . '/formatting.php'; 
  3.  
  4. // The result from _get_wptexturize_shortcode_regex(). Optional. 
  5. $shortcode_regex = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = _get_wptexturize_split_regex($shortcode_regex); 
  9.  

Defined (1)

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

/wp-includes/formatting.php  
  1. function _get_wptexturize_split_regex( $shortcode_regex = '' ) { 
  2. static $html_regex; 
  3.  
  4. if ( ! isset( $html_regex ) ) { 
  5. $comment_regex = 
  6. '!' // Start of comment, after the <. 
  7. . '(?:' // Unroll the loop: Consume everything until --> is found. 
  8. . '-(?!->)' // Dash not followed by end of comment. 
  9. . '[^\-]*+' // Consume non-dashes. 
  10. . ')*+' // Loop possessively. 
  11. . '(?:-->)?'; // End of comment. If not found, match all input. 
  12.  
  13. $html_regex = // Needs replaced with wp_html_split() per Shortcode API Roadmap. 
  14. '<' // Find start of element. 
  15. . '(?(?=!--)' // Is this a comment? 
  16. . $comment_regex // Find end of comment. 
  17. . '|' 
  18. . '[^>]*>?' // Find end of element. If not found, match all input. 
  19. . ')'; 
  20.  
  21. if ( empty( $shortcode_regex ) ) { 
  22. $regex = '/(' . $html_regex . ')/'; 
  23. } else { 
  24. $regex = '/(' . $html_regex . '|' . $shortcode_regex . ')/'; 
  25.  
  26. return $regex;