PCRE-Funktionen

Inhaltsverzeichnis

  • preg_filter — Sucht und ersetzt mit regulären Ausdrücken
  • preg_grep — Liefert Array-Elemente, die auf ein Suchmuster passen
  • preg_last_error — Liefert den Fehlercode der letzten PCRE RegEx-Auswertung
  • preg_match_all — Führt eine umfassende Suche nach Übereinstimmungen mit regulärem Ausdruck durch
  • preg_match — Führt eine Suche mit einem regulären Ausdruck durch
  • preg_quote — Maskiert Zeichen regulärer Ausdrücke
  • preg_replace_callback_array — Perform a regular expression search and replace using callbacks
  • preg_replace_callback — Sucht und ersetzt mit regulären Ausdrücken unter Verwendung eines Callbacks
  • preg_replace — Sucht und ersetzt mit regulären Ausdrücken
  • preg_split — Zerlegt eine Zeichenkette anhand eines regulären Ausdrucks
add a note add a note

User Contributed Notes 3 notes

up
11
Svoop
8 years ago
I have written a short introduction and a colorful cheat sheet for Perl Compatible Regular Expressions (PCRE):

http://www.bitcetera.com/en/techblog/2008/04/01/regex-in-a-nutshell/
up
2
stronk7 at moodle dot org
10 years ago
One comment about 5.2.x and the pcre.backtrack_limit:

Note that this setting wasn't present under previous PHP releases and the behaviour (or limit) under those releases was, in practise,  higher so all these PCRE functions were able to "capture" longer strings.

With the arrival of the setting, defaulting to 100000 (less than 100K), you won't be able to match/capture strings over that size using, for example "ungreedy" modifiers.

So, in a lot of situations, you'll need to raise that (very small IMO) limit.

The worst part is that PHP simply won't match/capture those strings over pcre.backtrack_limit and will it be 100% silent about that (I think that throwing some NOTICE/WARNING if raised could help a lot to developers).

There is a lot of people suffering this changed behaviour from I've read on forums, bugs and so on).

Hope this note helps, ciao :-)
up
2
steve at stevedix dot de
13 years ago
Something to bear in mind is that regex is actually a declarative programming language like prolog : your regex is a set of rules which the regex interpreter tries to match against a string.   During this matching, the interpreter will assume certain things, and continue assuming them until it er will a"ins't beex="htThr /rules which the arrival of the etera.com/en/techeitz.php"ef='>http://www.bitcetera.com/en/techeitz.php"ef='>idule