PHP.mk документација

PCRE функции

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

ref.pcre.php PHP.net прокси Преводот е вчитан
Оригинал на PHP.net
Патека ref.pcre.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + преведен приказ Кодовите, табелите и белешките остануваат читливи во истиот тек.
PCRE функции

Референца за `ref.pcre.php` со подобрена типографија и навигација.

ref.pcre.php

PCRE функции

Содржина

  • preg_filter — Изврши пребарување и замена со регуларен израз
  • preg_grep — Врати ги записите од низата што одговараат на образецот
  • preg_last_error — Враќа код за грешка од последното извршување на PCRE regex
  • preg_last_error_msg — Враќа порака за грешка од последното извршување на PCRE regex
  • preg_match — Изврши совпаѓање со регуларен израз
  • preg_match_all — Изврши глобално совпаѓање со регуларен израз
  • preg_quote — Квотирај ги знаците од регуларниот израз
  • preg_replace — Изврши пребарување и замена со регуларен израз
  • preg_replace_callback — Изврши пребарување и замена со регуларен израз користејќи повратен повик
  • preg_replace_callback_array — Изврши пребарување и замена со регуларен израз користејќи повратен повик
  • preg_split — Подели ја низата според регуларен израз

Белешки од корисници 3 белешки

steve на stevedix точка de
21 години пред
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 comes up against a failure to match, which then causes it to backtrack.  Regex assumes "greedy matching" unless explicitly told not to, which can cause a lot of backtracking.  A general rule of thumb is that the more backtracking, the slower the matching process.

It is therefore vital, if you are trying to optimise your program to run quickly (and if you can't do without regex), to optimise your regexes to match quickly.

I recommend the use of a tool such as "The Regex Coach" to debug your regex strings.

http://weitz.de/files/regex-coach.exe (Windows installer) http://weitz.de/files/regex-coach.tgz (Linux tar archive)
theking2 на king точка ma
пред 2 години
Writing regexp can be tedious and error prone. Test yours on https://regex101.com/ to make sure you haven't missed anything . It even colour codes example strings.
stronk7 на moodle точка org
пред 18 години
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 :-)
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.