Extract all examples from given $content.

@param string $content
@return array
190406
public function extractExamples($content)
    {
        $content = preg_replace('/^<\?(php)?/', '', $content);

        // So that you can separate examples
        // by an empty line.
        $examples = explode("\n\n", $content);

        $examples = array_filter($examples, function($example)
        {
            // Remove all \n's and see if
            // $example is still not empty.
            return str_replace("\n", "", $example);
        });

        // Recreate $examples to fix index order.
        // Array_filter won't do it for you.
        return array_values($examples);
    }
437119
protected function getExcerpt($content)
    {
        // Check for excerpt tags
        $pattern = '#(\<\!\-\-\s?excerpt\s?\-\-\>)(.*)(\<\!\-\-\s?endexcerpt\s?\-\-\>)#si';
        if (preg_match($pattern, $content, $matches)) {
            return $matches[2];
        }

        // If all else get the content from the first paragraph
        return $this->description;
    }
606400
public function exportFiles($content)
    {
        $images = [];
        if ($galleryData = $this->_defaultData($content)) {
            foreach ($galleryData as $image => $imageData) {
                $images[] = '/uploads/system/gallery/' . $this->_block->name . $imageData->path . $image;
            }
        }
        return $images;
    }
993341
public static function extractImports($content)
    {
        $imports = array();
        static::filterImports($content, function($matches) use(& $imports) {
            $imports[] = $matches['url'];
        });

        return array_unique($imports);
    }
43642
public function parse($content)
    {
        $tokens = $this->getTokens($content);

        $i = 0;
        $result = array();
        $currentMachine = '';

        while ($i < count($tokens)) {
            $currentToken = $tokens[$i];
            if ($currentToken == 'machine') {
                if (!isset($tokens[$i+1])) {
                    throw new ParseException("Cannot fetch machine name");
                }
                $currentMachine = $tokens[$i+1];
                $result[$currentMachine] = array();
                $i+=2;
            } else if ($currentToken == 'default') {
                $currentMachine = 'default';
                $result[$currentMachine] = array();
                $i++;
            } else {
                if (!in_array($currentToken, static::$netrcKeys)) {
                    throw new ParseException("Cannot handle unknown key '$currentToken' for '$currentMachine' machine");
                }
                if (!isset($tokens[$i+1])) {
                    throw new ParseException("Cannot fetch value of '$tokens[$i]' key for '$currentMachine' machine");
                }
                if (!$currentMachine) {
                    throw new ParseException("Cannot handle key '$currentToken' for unset machine");
                }
                $result[$currentMachine][$currentToken] = $tokens[$i+1];
                $i+=2;
            }
        }

        return $result;
    }
1172894
protected function _parseLoopEntities($content) {
		preg_match_all('/\bforeach \(\$([a-z]+) as \$([a-z]+)\)/i', $content, $matches);
		if (empty($matches[2])) {
			return [];
		}

		$result = [];

		foreach ($matches[2] as $key => $entity) {
			if (Inflector::pluralize($entity) !== $matches[1][$key]) {
				continue;
			}

			$entityName = Inflector::camelize(Inflector::underscore($entity));

			$className = App::className(($this->getConfig(static::CONFIG_PLUGIN) ? $this->getConfig(static::CONFIG_PLUGIN) . '.' : '') . $entityName, 'Model/Entity');
			if (!$className) {
				continue;
			}

			$result[$matches[1][$key]] = AnnotationFactory::createOrFail(VariableAnnotation::TAG, '\\' . $className . '[]|\Cake\Collection\CollectionInterface', '$' . $matches[1][$key]);
			// We do not need the singular then
			$result[$entity] = null;
		}

		return $result;
	}
1014866
public function contentFormatter($content)
    {
        $new_content = '';
        $pattern_full = '{(\[raw\].*?\[/raw\])}is';
        $pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
        $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);

        foreach ($pieces as $piece) {
            if (preg_match($pattern_contents, $piece, $matches)) {
                $new_content .= $matches[1];
            } else {
                $new_content .= wpautop($piece);
            }
        }

        return $new_content;
    }
18005
protected function restoreExtractedData($content)
    {
        if (!$this->extracted) {
            // nothing was extracted, nothing to restore
            return $content;
        }

        $content = strtr($content, $this->extracted);

        $this->extracted = array();

        return $content;
    }
893269
public function parse($content)
    {
        // if there is no path it's not needed to try to get a clean one
        if (empty($content)) return [];

        $path = $this->getCleanPath($content);
        $pathParts = [$this->delimiter];
        // check if there is even a need for further checks
        if (mb_strpos($path, $this->delimiter) === false) {
            if (!$path) {
                return [$this->delimiter];
            }

            // set the root and the path
            $tmpPathParts = [
                $this->delimiter,
                $path
            ];

            return $tmpPathParts;
        }

        // if there's a deeper path it's time to walk through it and clean the empty parts etc
        $tmpPathParts = explode($this->delimiter, $path);


        // walk through the array and remove the empty entries
        for ($i = 0, $c = count($tmpPathParts); $i < $c; $i++) {
            if (!$tmpPathParts[$i]) unset($tmpPathParts[$i]);
        }

        // prepend the default delimiter
        $pathParts = array_merge($pathParts, $tmpPathParts);

        // path parts
        return $pathParts;
    }
54718
public static function parse($content)
    {
        $matter = array();

        $text = str_replace(PHP_EOL, $id = uniqid(), $content);

        $regex = '/^---' . $id . '(.*?)' . $id . '---/';

        if (preg_match($regex, $text, $matches) === 1) {
            $yaml = str_replace($id, PHP_EOL, $matches[1]);

            $matter = (array) Yaml::parse(trim($yaml));

            $body = str_replace($matches[0], '', $text);

            $content = str_replace($id, PHP_EOL, $body);
        }

        return array($matter, (string) trim($content));
    }
1343176
private function recursivelyArrayify($content = null)
        {
            $return = [];
            if (false === $content || null === $content) {
                return;
            } else if ($content instanceof Element) {
                $return[] = $content->toArray();
            } else if (!is_array($content)) {
                $return[] = $content;
            } else {
                foreach ($content as $element) {
                    $return[] = $this->recursivelyArrayify($element);
                }
            }
            return $return;
        }
205098
protected function _getUsedModels($content) {
		preg_match_all('/\$this-\>loadModel\(\'([a-z.\/]+)\'/i', $content, $matches);
		if (empty($matches[1])) {
			return [];
		}

		$models = $matches[1];

		return array_unique($models);
	}
275539
public static function getHtmlAttributes($content)
    {
        $content = self::getHtmlTags($content, false);

        if (!is_array($content) || empty($content)) {
            return;
        }

        $content = implode($content);

        $re = '@(\s+)(\S+)=["\']?((?:.(?!["\']?\s+(?:\S+)=|[>]))+.)["\']?@';

        preg_match_all($re, $content, $matches, PREG_SET_ORDER, 0);

        $atts = array();
        if ($matches) {
            foreach ($matches as $match) {
                $atts[$match[2]] = $match[0];
            }

            return $atts;
        }

        return;
    }
848228
private static function getPlaceholders(string $content): array
    {
        $result = [];
        $matchCount = preg_match_all(static::getPlaceholderPattern(), $content, $result);

        if (false !== $matchCount && 0 < $matchCount) {
            foreach ($result as $index => $placeholders) {
                $result[$index] = array_unique($placeholders);
            }
        }

        return $result;
    }
115553
public function getFunctions(string $content): array
    {

        $functions = array();

        $tokenised_content = $this->getTokenisedContent($content);

        // Check for $tokenised_content["methods"];
        if (isset($tokenised_content["methods"])) {
            $functions = $tokenised_content["methods"];
        } elseif (isset($tokenised_content["functions"])) {
            $functions = $tokenised_content["functions"];
        }

        return $functions;

    }
1107837
private function getContentSubdocuments(Content $content)
    {
        if ($this->contentSubdocumentMapper->accept($content)) {
            return $this->contentSubdocumentMapper->mapDocuments($content);
        }

        return [];
    }
1260616
public function parse($content)
    {
        $set = null;
        if (strpos($content, '@ORM') === false) {
            return $set;
        }

        if (preg_match(self::PATTERN, $content, $matches)) {
            $set[] = [$matches[1], $matches[2]];
        }



        return $set;
    }