From 85eb0d98bb8d78ba2c7a5f10e2d77ffd8ddf4d73 Mon Sep 17 00:00:00 2001 From: Dmitry Mikhirev Date: Tue, 18 Nov 2014 16:15:56 +0300 Subject: README update --- README.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4cf310a..e420630 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ To get plugin built, simply type in source directory. Optionally, type - $ make check + $ make -k check to run self-tests. @@ -52,12 +52,25 @@ not expanded, but IN is expanded before search. Capturing strings ----------------- +### Capture by number ### + When matching found, `pcre_find` sets variable `$(0)` to whole matched string and variables `$(1)`, `$(2)`, ... to substrings captured by round brackets -(like perl does). Maximum number of strings that can be captured is 256 (`$(0)` +(like Perl does). Maximum number of strings that can be captured is 256 (`$(0)` to `$(255)`). These variables can be used until the next `pcre_find` call because it will reset them. +### Capture by name ### + +`pcre_find` also provides ability to set named variables to matched substrings. +It can be useful if you want to preserve captured value after another matching +function called or if your pattern is quiet complicated, and it is difficult +to handle substring numbers. + +In PCRE, a subpattern can be named in one of three ways: `(?...)` +or `(?'name'...)` as in Perl, or `(?P...)` as in Python. If pattern +matches, variable `$(name)` will be set to matched substring. + Options ------- -- cgit v1.2.1