Function __global->cms_preg_replace_safe

Definitions

sources/global3.php

  • Perform a regular expression search and replace.Automatically applies utf-8 if possible and appropriate. \s is not actually Unicode-safe, for example (as it matches non-breaking-spaces).Also automatically applies the 'D' modifier so that trailing blank lines don't mess with '$'.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$pattern mixed No No required parameter N/A N/A The pattern (string or array)
$replacement mixed No No required parameter N/A N/A The replacement string (string or array)
$subject string No No required parameter N/A N/A The subject string
$limit integer No No -1 N/A N/A The limit of replacements (-1: no limit)

Returns

  • The string with replacements made (false: error)
  • Type: ~string
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Perform a regular expression search and replace.Automatically applies utf-8 if possible and appropriate. \s is not actually Unicode-safe, for example (as it matches non-breaking-spaces).Also automatically applies the 'D' modifier so that trailing blank lines don't mess with '$'.
 *
 * @param  mixed $pattern The pattern (string or array)
 * @param  mixed $replacement The replacement string (string or array)
 * @param  string $subject The subject string
 * @param  integer $limit The limit of replacements (-1: no limit)
 * @return ~string The string with replacements made (false: error)
 */

function cms_preg_replace_safe($pattern, $replacement, string $subject, int $limit = -1)