PHP 8.3.4 Released!

mb_regex_set_options

(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)

mb_regex_set_optionsEstablece/obtiene las opciones predeterminadas para las funciones mbregex

Descripción

mb_regex_set_options(string $options = mb_regex_set_options()): string

Establece las opciones predeterminadas descritas por options para las funciones de expresiones regulares multibyte.

Parámetros

options

Las opciones a establecer. Es un estring donde cada carácter es una opción. Para establecer un modo, el carácter de dicho modo debe ser el último en establecerse, ya que solamente puede ser establecdio un modo, aunque múltiples opciones.

Opciones de expresiones regulares
Opción Significado
i Comparación ambigua activada
x Habilita la forma de patrones extendidos
m '.' coincide con nuevas líneas
s '^' -> '\A', '$' -> '\Z'
p Lo mismo que las opciones m y s juntas
l Busca las coincidencias más largas
n Ignora las coincidencias vacías
e Utiliza eval() con el código resultante
Modos de sintaxis de expresiones regulares
Modo Significado
j Java (Sun java.util.regex)
u Expresión regular GNU
g grep
c Emacs
r Ruby
z Perl
b Expresión regular POSIX Básica
d Expresión regular POSIX Extendida

Valores devueltos

Las opciones anteriores. Si se omite options, devuelve el string que describe las opciones actuales.

Ver también

  • mb_split() - Divide cadenas de caracteres multibyte usando una expresión regular
  • mb_ereg() - Comparación de expresiones regulares con soporte multibyte
  • mb_eregi() - Comparación de expresiones regulares ignorando mayúsculas/minúsculas con soporte multibyte

add a note

User Contributed Notes 2 notes

up
1
indeyets at php dot net
14 years ago
It's a bit trickier, than patryk wrote:

There are parameters (you can specify several of these at the same time):

'i': ONIG_OPTION_IGNORECASE;
'x': ONIG_OPTION_EXTEND;
'm': ONIG_OPTION_MULTILINE;
's': ONIG_OPTION_SINGLELINE;
'p': ONIG_OPTION_MULTILINE | ONIG_OPTION_SINGLELINE;
'l': ONIG_OPTION_FIND_LONGEST;
'n': ONIG_OPTION_FIND_NOT_EMPTY;
'e': eval() resulting code

And there are "modes" (if you specify several of these, the LAST one will be used):
'j': ONIG_SYNTAX_JAVA;
'u': ONIG_SYNTAX_GNU_REGEX;
'g': ONIG_SYNTAX_GREP;
'c': ONIG_SYNTAX_EMACS;
'r': ONIG_SYNTAX_RUBY;
'z': ONIG_SYNTAX_PERL;
'b': ONIG_SYNTAX_POSIX_BASIC;
'd': ONIG_SYNTAX_POSIX_EXTENDED;

You can find descriptions of these constants here: http://www.geocities.jp/kosako3/oniguruma/doc/API.txt
up
0
patryk dot szczyglowski at gmail dot com
15 years ago
Supported options are:

i - ONIG_OPTION_IGNORECASE
x - ONIG_OPTION_EXTEND
m - ONIG_OPTION_MULTILINE
s - ONIG_OPTION_SINGLELINE
p - ONIG_OPTION_MULTILINE | ONIG_OPTION_SINGLELINE
l - ONIG_OPTION_FIND_LONGEST
n - ONIG_OPTION_FIND_NOT_EMPTY
j - ONIG_SYNTAX_JAVA
u - ONIG_SYNTAX_GNU_REGEX
g - ONIG_SYNTAX_GREP
c - ONIG_SYNTAX_EMACS
r - ONIG_SYNTAX_RUBY
z - ONIG_SYNTAX_PERL
b - ONIG_SYNTAX_POSIX_BASIC
d - ONIG_SYNTAX_POSIX_EXTENDED
e - eval() resulting code

Constants above are from Oniguruma regexp library, which is used internally. Default value for PHP 5.2.x is 'pr'.
To Top