Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

mb_ereg_match

Description

The mb_ereg_match of Multibyte String for PHP regular expression match for multibyte string.

Syntax

mb_ereg_match(
    string $pattern,
    string $string,
    ?string $options = null
): bool

Parameters

pattern

The regular expression pattern.

string

The string being evaluated.

options

The search option.

OptionDescription
iAmbiguity match on
xEnables extended pattern form
m'.' matches with newlines
s'^' -> '\A', '$' -> '\Z'
pSame as both the m and s options
lFinds longest matches
nIgnores empty matches

Return

Returns true if string matches the regular expression pattern, false if not.

Examples

1 · pattern string

<?

$pattern = '🐘(st(r(i)ng))';
$string = '🐘string';

$return = mb_ereg_match($pattern, $string);

var_export($return);

?>
true

2 · options · i

<?

$pattern = '🐘STRING';
$string = '🐘string';
$options = 'i';

$return = mb_ereg_match($pattern, $string, $options);

var_export($return);

?>
true

3 · options · x

<?

$pattern = '🐘 s t r i n g';
$string = '🐘string';
$options = 'x';

$return = mb_ereg_match($pattern, $string, $options);

var_export($return);

?>
true

4 · options · m

<?

$pattern = '.🐘string';
$string = '
🐘string';
$options = 'm';

$return = mb_ereg_match($pattern, $string, $options);

var_export($return);

?>
true

5 · options · s

<?

$pattern = '^🐘string$';
$string = '🐘string';
$options = 's';

$return = mb_ereg_match($pattern, $string, $options);

var_export($return);

?>
true

6 · options · p

<?

$pattern = '^.🐘string$';
$string = '
🐘string';
$options = 'p';

$return = mb_ereg_match($pattern, $string, $options);

var_export($return);

?>
true

7 · options · l

<?

$pattern = '🐘.*tring';
$string = '🐘stringtring';
$options = 'l';

$return = mb_ereg_match($pattern, $string, $options);

var_export($return);

?>
true

8 · options · n

<?

$pattern = '';
$string = '🐘string';
$options = 'n';

$return = mb_ereg_match($pattern, $string, $options);

var_export($return);

?>
false
HomeMenu