You are here

public static function TwigTweakExtension::pregReplaceFilter in Twig Tweak 3.1.x

Same name and namespace in other branches
  1. 3.x src/TwigTweakExtension.php \Drupal\twig_tweak\TwigTweakExtension::pregReplaceFilter()

Performs a regular expression search and replace.

Parameters

string $text: The text to search and replace.

string $pattern: The pattern to search for.

string $replacement: The string to replace.

Return value

string The new text if matches are found, otherwise unchanged text.

File

src/TwigTweakExtension.php, line 467

Class

TwigTweakExtension
Twig extension with some useful functions and filters.

Namespace

Drupal\twig_tweak

Code

public static function pregReplaceFilter(string $text, string $pattern, string $replacement) : string {
  return preg_replace($pattern, $replacement, $text);
}