get_html_split_regex

Retrieve the regular expression for an HTML element.

Description

(string) get_html_split_regex(); 

Returns (string)

The regular expression


Usage

  1. if ( !function_exists( 'get_html_split_regex' ) ) { 
  2. require_once ABSPATH . WPINC . '/formatting.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = get_html_split_regex(); 
  7.  

Defined (1)

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

/wp-includes/formatting.php  
  1. function get_html_split_regex() { 
  2. static $regex; 
  3.  
  4. if ( ! isset( $regex ) ) { 
  5. $comments = 
  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. $cdata = 
  14. '!\[CDATA\[' // Start of comment, after the <. 
  15. . '[^\]]*+' // Consume non-]. 
  16. . '(?:' // Unroll the loop: Consume everything until ]]> is found. 
  17. . '](?!]>)' // One ] not followed by end of comment. 
  18. . '[^\]]*+' // Consume non-]. 
  19. . ')*+' // Loop possessively. 
  20. . '(?:]]>)?'; // End of comment. If not found, match all input. 
  21.  
  22. $escaped = 
  23. '(?=' // Is the element escaped? 
  24. . '!--' 
  25. . '|' 
  26. . '!\[CDATA\[' 
  27. . ')' 
  28. . '(?(?=!-)' // If yes, which type? 
  29. . $comments 
  30. . '|' 
  31. . $cdata 
  32. . ')'; 
  33.  
  34. $regex = 
  35. '/(' // Capture the entire match. 
  36. . '<' // Find start of element. 
  37. . '(?' // Conditional expression follows. 
  38. . $escaped // Find end of escaped element. 
  39. . '|' // ... else ... 
  40. . '[^>]*>?' // Find end of normal element. 
  41. . ')' 
  42. . ')/'; 
  43.  
  44. return $regex;