_get_wptexturize_shortcode_regex

Retrieve the regular expression for shortcodes.

Description

(string) _get_wptexturize_shortcode_regex( (string) $tagnames ); 

Returns (string)

The regular expression

Parameters (1)

0. $tagnames (string)
List of shortcodes to find.

Usage

  1. if ( !function_exists( '_get_wptexturize_shortcode_regex' ) ) { 
  2. require_once ABSPATH . WPINC . '/formatting.php'; 
  3.  
  4. // List of shortcodes to find. 
  5. $tagnames = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = _get_wptexturize_shortcode_regex($tagnames); 
  9.  

Defined (1)

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

/wp-includes/formatting.php  
  1. function _get_wptexturize_shortcode_regex( $tagnames ) { 
  2. $tagregexp = join( '|', array_map( 'preg_quote', $tagnames ) ); 
  3. $tagregexp = "(?:$tagregexp)(?=[\\s\\]\\/])"; // Excerpt of get_shortcode_regex(). 
  4. $regex = 
  5. '\[' // Find start of shortcode. 
  6. . '[\/\[]?' // Shortcodes may begin with [/ or [[ 
  7. . $tagregexp // Only match registered shortcodes, because performance. 
  8. . '(?:' 
  9. . '[^\[\]<>]+' // Shortcodes do not contain other shortcodes. Quantifier critical. 
  10. . '|' 
  11. . '<[^\[\]>]*>' // HTML elements permitted. Prevents matching ] before >. 
  12. . ')*+' // Possessive critical. 
  13. . '\]' // Find end of shortcode. 
  14. . '\]?'; // Shortcodes may end with ]] 
  15.  
  16. return $regex;