downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

Instalación/Configuración> <PCRE
[edit] Last updated: Fri, 07 Jun 2013

view this page in

Introducción

La sintaxis de los patrones usados en estas funciones se parece mucho a la de Perl. La expresión se debe encerrar entre unos delimitadores, una barra (/), por ejemplo. Los delimitadores pueden ser cualquier carácter no alfanumérico, cualquier carácter ASCII que no sea de tipo espacio en blanco, excepto la barra invertida (\), y el byte null. Si el carácter delimitador va a ser usado en la expresión misma, es necesario escaparlo con la barra invertida. A partir de PHP 4.0.4, se pueden usar los delimitadores estilo Perl (), {}, [], y <>. Véase Sintaxis de Patrón para una explicación detallada.

Al delimitador final le pueden seguir varios modificadores que afectan a la comparación. Véase Modificadores de Patrón.

PHP tambíén admite expresiones regulares empleando una sintaxis POSIX extendido usando las Funciones de expresiones regulares POSIX extendido.

Nota:

Estas extensiones mantienen una caché global por hilo de expresiones regulares compiladas (hasta 4096).

Advertencia

Debería considerar algunas limitaciones de PCRE. Lea » http://www.pcre.org/pcre.txt para más información.

La biblioteca PCRE es un conjunto de funciones que implementan comparaciones de patrones de expresiones regulares usando la misma sintaxis y semántica que Perl 5, con muy pocas diferencias (véase más adelante). La implementación actual corresponde a Perl 5.005.



add a note add a note User Contributed Notes Introducción - [1 notes]
up
-2
m dot colombo at NOSPAM dot esi dot it
3 years ago
Converting POSIX regex patters to PCRE is non-trivial. I had many (about 17.000) patterns stored in a DB, and found that surrounding one with delimiters (such as '/'), after quoting them, is not enough.

I've been biten by a \r that slipped into a pattern (that was supposed to be \.r and became .\r instead). Too bad in PCRE it stands for carriage-return.

AFAIK, there's no way to disable this behaviour and make PCRE more POSIX compatibile. You have to look for every single escape sequence that has no meaning in POSIX regex but has one in PCRE and remove the backslash.

Before POSIX regex are removed it would be really cool to have a function that converts a POSIX regex pattern into the equivalent PCRE one.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites