You are here

function oembed_scheme_to_regex in oEmbed 7

Same name and namespace in other branches
  1. 8 oembed.oembed.inc \oembed_scheme_to_regex()
  2. 7.0 oembed.oembed.inc \oembed_scheme_to_regex()

Helper function that changes oEmbed schemes to regular expressions.

1 call to oembed_scheme_to_regex()
oembed_provider_process in ./oembed.oembed.inc

File

./oembed.oembed.inc, line 74

Code

function oembed_scheme_to_regex($scheme, $capture_subpatterns = FALSE) {
  $patterns = array();
  $schemes = array_filter(preg_split("/(\r\n?|\n)/", $scheme));
  foreach ($schemes as $scheme) {
    $patterns[] = str_replace('\\*', $capture_subpatterns ? '(.*)' : '.*', preg_quote($scheme, '#'));
  }
  return '#' . implode('|', $patterns) . '#i';
}