Function __global->cms_preg_match_safe
Definitions
sources/global3.php
- Perform a regular expression match.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 |
| $subject | string | No | No | required parameter | N/A | N/A | The subject string |
| &$matches | ?array | Yes | No | Null | N/A | N/A | Where matches will be put (note that it is a list of maps, except the arrays are turned inside out) (null: do not store matches). Note that this is actually passed by reference, but is also optional. (null: don't gather) |
| $flags | integer | No | No | 0 | N/A | N/A | Either 0, or PREG_OFFSET_CAPTURE |
| $offset | integer | No | No | 0 | N/A | N/A | Offset to start from. Usually use with 'A' modifier to anchor it (using '^' in the pattern will not work) |
Returns
- The number of matches (false: error)
- Type: ~integer
- Set: N/A
- Range: N/A
Preview
Code (PHP)
/**
* Perform a regular expression match.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 string $subject The subject string
* @param ?array $matches Where matches will be put (note that it is a list of maps, except the arrays are turned inside out) (null: do not store matches). Note that this is actually passed by reference, but is also optional. (null: don't gather)
* @param integer $flags Either 0, or PREG_OFFSET_CAPTURE
* @param integer $offset Offset to start from. Usually use with 'A' modifier to anchor it (using '^' in the pattern will not work)
* @return ~integer The number of matches (false: error)
*/
function cms_preg_match_safe(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0)
* Perform a regular expression match.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 string $subject The subject string
* @param ?array $matches Where matches will be put (note that it is a list of maps, except the arrays are turned inside out) (null: do not store matches). Note that this is actually passed by reference, but is also optional. (null: don't gather)
* @param integer $flags Either 0, or PREG_OFFSET_CAPTURE
* @param integer $offset Offset to start from. Usually use with 'A' modifier to anchor it (using '^' in the pattern will not work)
* @return ~integer The number of matches (false: error)
*/
function cms_preg_match_safe(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0)

