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

mb_eregi_replace

Description

The mb_eregi_replace of Multibyte String for PHP replace regular expression with multibyte support ignoring case.

Syntax

mb_eregi_replace(
    string $pattern,
    string $replacement,
    string $string,
    ?string $options = null
): string|false|null

Parameters

pattern

The regular expression pattern. Multibyte characters may be used. The case will be ignored.

replacement

The replacement text.

string

The searched string.

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

The resultant string or false on error. If string is not valid for the current encoding, null is returned.

Examples

1 · pattern replacement string

<?

$pattern = '🐘STRING';
$replacement = 'replacement';
$string = '🐘string';

$return = mb_eregi_replace($pattern, $replacement, $string);

var_export($return);
'replacement'

2 · options · i

<?

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

$return = mb_eregi_replace($pattern, $replacement, $string, $options);

var_export($return);
'replacement'

3 · options · x

<?

$pattern = '🐘 S T R I N G';
$replacement = 'replacement';
$string = '🐘string';
$options = 'x';

$return = mb_eregi_replace($pattern, $replacement, $string, $options);

var_export($return);
'replacement'

4 · options · m

<?

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

$return = mb_eregi_replace($pattern, $replacement, $string, $options);

var_export($return);
'replacement'

5 · options · s

<?

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

$return = mb_eregi_replace($pattern, $replacement, $string, $options);

var_export($return);
'replacement'

6 · options · p

<?

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

$return = mb_eregi_replace($pattern, $replacement, $string, $options);

var_export($return);
'replacement'

7 · options · l

<?

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

$return = mb_eregi_replace($pattern, $replacement, $string, $options);

var_export($return);
'replacement'

8 · options · n

<?

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

$return = mb_eregi_replace($pattern, $replacement, $string, $options);

var_export($return);
'🐘string'