You are here

function _ckeditor_filter_styles_regex_builder in CKEditor Filter 7

Builds regex http://stackoverflow.com/questions/12412388/regex-to-remove-all-styles-b...

1 call to _ckeditor_filter_styles_regex_builder()
_ckeditor_filter_process in ./ckeditor_filter.module
Process callback for filter.

File

./ckeditor_filter.module, line 77
Provides an input filter that allows site administrators configure which HTML elements, attributes and style properties are allowed.

Code

function _ckeditor_filter_styles_regex_builder($styles) {
  if (!empty($styles)) {
    $regex = '/(?:';
    foreach ($styles as $style) {
      $regex .= '(?!(?:|[^$]*[;\\s])' . $style . '\\s*:[^$;]*)';
    }
    $regex .= '[^$]*$|';
    foreach ($styles as $style) {
      $regex .= '(?=(?:|[^$]*[;\\s])(' . $style . '\\s*:[^$;]*))?';
    }
    return $regex . '[^$]*$)/i';
  }
  return FALSE;
}