You are here

function _shortcode_get_shortcode_regex in Shortcode 7.2

Same name and namespace in other branches
  1. 6 shortcode.module \_shortcode_get_shortcode_regex()
  2. 7 shortcode.module \_shortcode_get_shortcode_regex()

Retrieve the ShortCode regular expression for searching.

The regular expression combines the ShortCode tags in the regular expression in a regex class.

The regular expression contains 6 different sub matches to help with parsing.

1/6 - An extra [ or ] to allow for escaping ShortCodes with double [[]] 2 - The ShortCode name 3 - The ShortCode argument list 4 - The self closing / 5 - The content of a ShortCode when it wraps some content.

Parameters

array $names: The tag names.

Return value

string The ShortCode search regular expression

File

./shortcode.module, line 440
Provides ShortCodes filter framework and API (like WP ShortCodes)

Code

function _shortcode_get_shortcode_regex(array $names) {
  $tagregexp = implode('|', array_map('preg_quote', $names));

  // WARNING! Do not change this regex without changing do_shortcode_tag()
  // and strip_shortcodes().
  return '(.?)\\[(' . $tagregexp . ')\\b(.*?)(?:(\\/))?\\](?:(.+?)\\[\\/\\2\\])?(.?)';
}