NAME
pcre - Perl-compatible regular expressions.
SYNOPSIS
#include <pcre.h>
pcre *pcre_compile(const char *pattern, int options,
const char **errptr, int *erroffset,
const unsigned char *tableptr);
pcre_extra *pcre_study(const pcre *code, int options,
const char **errptr);
int pcre_exec(const pcre *code, const pcre_extra *extra,
const char *subject, int length, int startoffset,
int options, int *ovector, int ovecsize);
int pcre_copy_substring(const char *subject, int *ovector,
int stringcount, int stringnumber, char *buffer,
int buffersize);
int pcre_get_substring(const char *subject, int *ovector,
int stringcount, int stringnumber,
const char **stringptr);
int pcre_get_substring_list(const char *subject,
int *ovector, int stringcount, const char ***listptr);
void pcre_free_substring(const char *stringptr);
void pcre_free_substring_list(const char **stringptr);
const unsigned char *pcre_maketables(void);
int pcre_fullinfo(const pcre *code, const pcre_extra *extra,
int what, void *where);
int pcre_info(const pcre *code, int *optptr, *firstcharptr);
char *pcre_version(void);
void *(*pcre_malloc)(size_t);
void (*pcre_free)(void *);
DESCRIPTION
The PCRE library is a set of functions that implement regu-
lar expression pattern matching using the same syntax and
semantics as Perl 5, with just a few differences (see
below). The current implementation corresponds to Perl
5.005, with some additional features from later versions.
This includes some experimental, incomplete support for
UTF-8 encoded strings. Details of exactly what is and what
is not supported are given below.
PCRE has its own native API, which is described in this
document. There is also a set of wrapper functions that
correspond to the POSIX regular expression API. These are
described in the pcreposix documentation.
The native API function prototypes are defined in the header
file pcre.h, and on Unix systems the library itself is
called libpcre.a, so can be accessed by adding -lpcre to the
command for linking an application which calls it. The
header file defines the macros PCRE_MAJOR and PCRE_MINOR to
contain the major and minor release numbers for the library.
Applications can use these to include support for different
releases.
The functions pcre_compile(), pcre_study(), and pcre_exec()
are used for compiling and matching regular expressions. A
sample program that demonstrates the simplest way of using
them is given in the file pcredemo.c. The last section of
this man page describes how to run it.
The functions pcre_copy_substring(), pcre_get_substring(),
and pcre_get_substring_list() are convenience functions for
extracting captured substrings from a matched subject
string; pcre_free_substring() and pcre_free_substring_list()
are also provided, to free the memory used for extracted
strings.
The function pcre_maketables() is used (optionally) to build
a set of character tables in the current locale for passing
to pcre_compile().
The function pcre_fullinfo() is used to find out information
about a compiled pattern; pcre_info() is an obsolete version
which returns only some of the available information, but is
retained for backwards compatibility. The function
pcre_version() returns a pointer to a string containing the
version of PCRE and its date of release.
The global variables pcre_malloc and pcre_free initially
contain the entry points of the standard malloc() and free()
functions respectively. PCRE calls the memory management
functions via these variables, so a calling program can
replace them if it wishes to intercept the calls. This
should be done before calling any PCRE functions.
MULTI-THREADING
The PCRE functions can be used in multi-threading applica-
tions, with the proviso that the memory management functions
pointed to by pcre_malloc and pcre_free are shared by all
threads.
The compiled form of a regular expression is not altered
during matching, so the same compiled pattern can safely be
used by several threads at once.
COMPILING A PATTERN
The function pcre_compile() is called to compile a pattern
into an internal form. The pattern is a C string terminated
by a binary zero, and is passed in the argument pattern. A
pointer to a single block of memory that is obtained via
pcre_malloc is returned. This contains the compiled code and
related data. The pcre type is defined for the returned
block; this is a typedef for a structure whose contents are
not externally defined. It is up to the caller to free the
memory when it is no longer required.
Although the compiled code of a PCRE regex is relocatable,
that is, it does not depend on memory location, the complete
pcre data block is not fully relocatable, because it con-
tains a copy of the tableptr argument, which is an address
(see below).
The size of a compiled pattern is roughly proportional to
the length of the pattern string, except that each character
class (other than those containing just a single character,
negated or not) requires 33 bytes, and repeat quantifiers
with a minimum greater than one or a bounded maximum cause
the relevant portions of the compiled pattern to be repli-
cated.
The options argument contains independent bits that affect
the compilation. It should be zero if no options are
required. Some of the options, in particular, those that are
compatible with Perl, can also be set and unset from within
the pattern (see the detailed description of regular expres-
sions below). For these options, the contents of the options
argument specifies their initial settings at the start of
compilation and execution. The PCRE_ANCHORED option can be
set at the time of matching as well as at compile time.
If errptr is NULL, pcre_compile() returns NULL immediately.
Otherwise, if compilation of a pattern fails, pcre_compile()
returns NULL, and sets the variable pointed to by errptr to
point to a textual error message. The offset from the start
of the pattern to the character where the error was
discovered is placed in the variable pointed to by
erroffset, which must not be NULL. If it is, an immediate
error is given.
If the final argument, tableptr, is NULL, PCRE uses a
default set of character tables which are built when it is
compiled, using the default C locale. Otherwise, tableptr
must be the result of a call to pcre_maketables(). See the
section on locale support below.
This code fragment shows a typical straightforward call to
pcre_compile():
pcre *re;
const char *error;
int erroffset;
re = pcre_compile(
"^A.*Z", /* the pattern */
0, /* default options */
&error, /* for error message */
&erroffset, /* for error offset */
NULL); /* use default character tables */
The following option bits are defined in the header file:
PCRE_ANCHORED
If this bit is set, the pattern is forced to be "anchored",
that is, it is constrained to match only at the start of the
string which is being searched (the "subject string"). This
effect can also be achieved by appropri
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Apache Web Server V2.0.40 (1889个子文件)
pcretest.1 11KB
htpasswd.1 8KB
dbmmanage.1 6KB
htdigest.1 4KB
pcregrep.1 3KB
pgrep.1 2KB
pcre.3 87KB
pcreposix.3 6KB
apxs.8 12KB
ab.8 8KB
httpd.8 5KB
apachectl.8 5KB
rotatelogs.8 5KB
logresolve.8 3KB
suexec.8 3KB
ABOUT_APACHE 15KB
APRDesign 15KB
AUTHORS 179B
win32ver.awk 3KB
win32ver.awk 3KB
make_exports.awk 3KB
make_exports.awk 3KB
mkconfNW.awk 3KB
MakeWin32Make.awk 2KB
make_nw_export.awk 2KB
make_nw_export.awk 2KB
build-modules-c.awk 2KB
make_var_export.awk 1021B
make_var_export.awk 1021B
prebuildNW.bat 2KB
prebuildNW.bat 2KB
apache_header.bmp 6KB
srun.bmp 246B
sstop.bmp 246B
bsd_makefile 3KB
buildconf 5KB
buildconf 4KB
buildconf 566B
mod_dav.c 163KB
pcre.c 150KB
mod_rewrite.c 136KB
core.c 133KB
mod_include.c 127KB
xmlparse.c 124KB
http_protocol.c 105KB
mod_negotiation.c 103KB
threadpool.c 81KB
ssl_util_table.c 81KB
worker.c 77KB
proxy_ftp.c 72KB
leader.c 72KB
mod_auth_digest.c 72KB
mod_autoindex.c 71KB
request.c 69KB
perchild.c 68KB
ssl_engine_kernel.c 65KB
repos.c 65KB
util.c 65KB
mod_mime_magic.c 64KB
ab.c 63KB
config.c 62KB
mpm_winnt.c 59KB
apr_pools.c 58KB
ApacheMonitor.c 58KB
mod_isapi.c 57KB
ssl_scache_shmcb.c 54KB
protocol.c 53KB
mod_cgid.c 52KB
util.c 51KB
mod_example.c 51KB
service.c 49KB
ssl_expr_scan.c 48KB
prefork.c 45KB
proxy_http.c 44KB
apr_tables.c 43KB
lock.c 42KB
mpm_netware.c 41KB
mod_charset_lite.c 41KB
xmltok_impl.c 40KB
mod_log_config.c 40KB
beos.c 39KB
mod_proxy.c 39KB
ssl_engine_config.c 38KB
apr_snprintf.c 37KB
ssl_engine_init.c 37KB
xmltok.c 37KB
mod_cache.c 37KB
filepath.c 37KB
mod_cgi.c 37KB
child.c 36KB
props.c 36KB
proxy_util.c 35KB
mod_mem_cache.c 35KB
mod_mime.c 34KB
vhost.c 34KB
ssl_expr_parse.c 33KB
pcretest.c 33KB
sendrecv.c 31KB
ssl_engine_pphrase.c 30KB
ssl_engine_io.c 30KB
共 1889 条
- 1
- 2
- 3
- 4
- 5
- 6
- 19
资源评论
- okboy19892014-10-17正好要用 感谢!
- 大唐李靖2013-02-25不是WINDOWS 下安装的,不太方便,要很专业才行,初学者不要下载这个
- moomayeasy2015-08-07正好要用 挺好
- happen29192016-07-12挺好的,就是配置起来太麻烦,按照网上下的教程配置,没成功
普通网友
- 粉丝: 882
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功