Function __global->cms_preg_replace_callback_safe
Definitions
sources/global3.php
- Perform a regular expression search and replace using a callback.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 | string | No | No | required parameter | N/A | N/A | The pattern |
| $callback | mixed | No | No | required parameter | N/A | N/A | The callback |
| $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 using a callback.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 string $pattern The pattern
* @param mixed $callback The callback
* @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_callback_safe(string $pattern, $callback, string $subject, int $limit = -1)
* Perform a regular expression search and replace using a callback.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 string $pattern The pattern
* @param mixed $callback The callback
* @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_callback_safe(string $pattern, $callback, string $subject, int $limit = -1)

