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

search for in the

Installation/Configuration> <PCRE
[edit] Last updated: Fri, 24 May 2013

view this page in

Introduction

La syntaxe des masques utilisés dans ces fonctions ressemble fort à celle de Perl. Les expressions seront entourées de délimiteurs, slash (/), par exemple. Un délimiteur peut être n'importe quel caractère, tant qu'il n'est pas alphanumérique, un caractère blanc, l'antislash (\) ou le caractère nul (\0). Si un délimiteur doit être utilisé dans l'expression, il faudra le protéger avec un antislash. Depuis PHP 4.0.4, vous pouvez utiliser les délimiteurs (), {}, [], et <>, comme en Perl. Voir la syntaxe des masques pour plus d'explications.

Le délimiteur final peut être suivi d'options qui affecteront la recherche. Voir aussi options de recherche.

PHP supporte également les expressions rationnelles utilisant la syntaxe POSIX étendue (fonctions REGEX POSIX-extended).

Note:

Cette extension maintient un cache global par thread des expressions rationnelles compilées (jusqu'à 4096).

Avertissement

Vous devez être conscient des limitations de PCRE. Lisez » http://www.pcre.org/pcre.txt pour plus de détails.

La bibliothèque PCRE est un ensemble de fonctions qui implémentent les expressions rationnelles en utilisant la même syntaxe et sémantique que Perl 5 avec seulement quelques différence (voir plus bas). L'implémentation courante correspond à Perl 5.005.



add a note add a note User Contributed Notes Introduction - [1 notes]
up
-1
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 | sitemap | contact | advertising | mirror sites