You are here

public function CollapseText::findTags in Collapse Text 2.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/Filter/CollapseText.php \Drupal\collapse_text\Plugin\Filter\CollapseText::findTags()

Helper function to find all of the [collapse...] tags location.

1 call to CollapseText::findTags()
CollapseText::process in src/Plugin/Filter/CollapseText.php
Performs the filter processing.

File

src/Plugin/Filter/CollapseText.php, line 474

Class

CollapseText
Provides a filter to display Collapsible text blocks.

Namespace

Drupal\collapse_text\Plugin\Filter

Code

public function findTags($text, $options) {
  $matches = [];
  $regex = '/
      (?<!\\\\)     # not proceeded by a backslash
      \\[            # opening bracket
      \\/?           # a closing tag?
      collapse      # the word collapse
      [^\\]]*        # everything until the closing bracket
      \\]            # a closing bracket
    /smx';
  preg_match_all($regex, $text, $matches, PREG_OFFSET_CAPTURE);
  return $matches[0];
}