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
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共2000个文件
c:479个
h:230个
xml:170个
最流行的Web服务器软件。Linux + Apache是目前免费服务器中的最佳拍挡。Apache快速、可靠、可通过简单的API扩展,Perl/Python解释器可被编译到服务器中,完全免费,完全源代码开放。如果你需要创建一个每天有数百万人访问的Web服务器,Apache可能是最佳选择。
资源推荐
资源详情
资源评论
收起资源包目录
Apache HTTP Server for Linux V2.0.49 (2000个子文件)
pcretest.1 11KB
htpasswd.1 6KB
dbmmanage.1 5KB
pcregrep.1 3KB
pgrep.1 2KB
htdigest.1 2KB
pcre.3 87KB
pcreposix.3 6KB
apxs.8 10KB
ab.8 6KB
httpd.8 4KB
apachectl.8 4KB
rotatelogs.8 3KB
logresolve.8 1KB
suexec.8 1KB
ABOUT_APACHE 15KB
AUTHORS 179B
win32ver.awk 4KB
make_exports.awk 4KB
mkconfNW.awk 3KB
win32ver.awk 3KB
make_exports.awk 3KB
make_nw_export.awk 2KB
build-modules-c.awk 2KB
MakeWin32Make.awk 2KB
make_nw_export.awk 2KB
make_var_export.awk 2KB
nw_ver.awk 1KB
make_var_export.awk 1023B
nw_ver.awk 668B
prebuildNW.bat 2KB
prebuildNW.bat 2KB
index.html.zh-tw.big5 1KB
apache_header.bmp 6KB
srun.bmp 246B
sstop.bmp 246B
bsd_makefile 1000B
buildconf 5KB
buildconf 4KB
buildconf 1KB
mod_dav.c 167KB
pcre.c 150KB
mod_rewrite.c 144KB
core.c 142KB
mod_include.c 128KB
xmlparse.c 124KB
http_protocol.c 106KB
mod_negotiation.c 105KB
ssl_util_table.c 79KB
threadpool.c 77KB
worker.c 73KB
util.c 72KB
mod_autoindex.c 72KB
proxy_ftp.c 70KB
repos.c 70KB
leader.c 68KB
perchild.c 67KB
request.c 67KB
mod_auth_digest.c 67KB
ab.c 63KB
config.c 63KB
mod_mime_magic.c 62KB
ssl_engine_kernel.c 61KB
mpm_winnt.c 59KB
mod_isapi.c 59KB
apr_pools.c 58KB
util.c 58KB
mod_cgid.c 58KB
ApacheMonitor.c 56KB
ssl_scache_shmcb.c 52KB
ssl_engine_io.c 49KB
mod_example.c 49KB
protocol.c 49KB
service.c 46KB
ssl_expr_scan.c 46KB
mod_log_config.c 45KB
proxy_http.c 44KB
util_ldap.c 43KB
prefork.c 41KB
mpm_netware.c 41KB
lock.c 40KB
xmltok_impl.c 40KB
mod_charset_lite.c 39KB
apr_snprintf.c 39KB
ssl_engine_config.c 39KB
mod_mem_cache.c 38KB
child.c 38KB
apr_tables.c 38KB
mod_auth_ldap.c 38KB
beos.c 37KB
mod_proxy.c 37KB
props.c 37KB
xmltok.c 37KB
mod_cache.c 37KB
filepath.c 36KB
ssl_engine_init.c 36KB
mod_cgi.c 35KB
proxy_util.c 35KB
ssl_expr_parse.c 33KB
pcretest.c 33KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- snowe0002012-09-06在SUSE上部署起来,还不错
普通网友
- 粉丝: 882
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功