/[pcre]/code/trunk/doc/pcreapi.3
ViewVC logotype

Diff of /code/trunk/doc/pcreapi.3

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 96 by nigel, Fri Mar 2 13:10:43 2007 UTC revision 149 by ph10, Mon Apr 16 15:28:08 2007 UTC
# Line 7  PCRE - Perl-compatible regular expressio Line 7  PCRE - Perl-compatible regular expressio
7  .B #include <pcre.h>  .B #include <pcre.h>
8  .PP  .PP
9  .SM  .SM
 .br  
10  .B pcre *pcre_compile(const char *\fIpattern\fP, int \fIoptions\fP,  .B pcre *pcre_compile(const char *\fIpattern\fP, int \fIoptions\fP,
11  .ti +5n  .ti +5n
12  .B const char **\fIerrptr\fP, int *\fIerroffset\fP,  .B const char **\fIerrptr\fP, int *\fIerroffset\fP,
13  .ti +5n  .ti +5n
14  .B const unsigned char *\fItableptr\fP);  .B const unsigned char *\fItableptr\fP);
15  .PP  .PP
 .br  
16  .B pcre *pcre_compile2(const char *\fIpattern\fP, int \fIoptions\fP,  .B pcre *pcre_compile2(const char *\fIpattern\fP, int \fIoptions\fP,
17  .ti +5n  .ti +5n
18  .B int *\fIerrorcodeptr\fP,  .B int *\fIerrorcodeptr\fP,
# Line 23  PCRE - Perl-compatible regular expressio Line 21  PCRE - Perl-compatible regular expressio
21  .ti +5n  .ti +5n
22  .B const unsigned char *\fItableptr\fP);  .B const unsigned char *\fItableptr\fP);
23  .PP  .PP
 .br  
24  .B pcre_extra *pcre_study(const pcre *\fIcode\fP, int \fIoptions\fP,  .B pcre_extra *pcre_study(const pcre *\fIcode\fP, int \fIoptions\fP,
25  .ti +5n  .ti +5n
26  .B const char **\fIerrptr\fP);  .B const char **\fIerrptr\fP);
27  .PP  .PP
 .br  
28  .B int pcre_exec(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"  .B int pcre_exec(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"
29  .ti +5n  .ti +5n
30  .B "const char *\fIsubject\fP," int \fIlength\fP, int \fIstartoffset\fP,  .B "const char *\fIsubject\fP," int \fIlength\fP, int \fIstartoffset\fP,
31  .ti +5n  .ti +5n
32  .B int \fIoptions\fP, int *\fIovector\fP, int \fIovecsize\fP);  .B int \fIoptions\fP, int *\fIovector\fP, int \fIovecsize\fP);
33  .PP  .PP
 .br  
34  .B int pcre_dfa_exec(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"  .B int pcre_dfa_exec(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"
35  .ti +5n  .ti +5n
36  .B "const char *\fIsubject\fP," int \fIlength\fP, int \fIstartoffset\fP,  .B "const char *\fIsubject\fP," int \fIlength\fP, int \fIstartoffset\fP,
# Line 44  PCRE - Perl-compatible regular expressio Line 39  PCRE - Perl-compatible regular expressio
39  .ti +5n  .ti +5n
40  .B int *\fIworkspace\fP, int \fIwscount\fP);  .B int *\fIworkspace\fP, int \fIwscount\fP);
41  .PP  .PP
 .br  
42  .B int pcre_copy_named_substring(const pcre *\fIcode\fP,  .B int pcre_copy_named_substring(const pcre *\fIcode\fP,
43  .ti +5n  .ti +5n
44  .B const char *\fIsubject\fP, int *\fIovector\fP,  .B const char *\fIsubject\fP, int *\fIovector\fP,
# Line 53  PCRE - Perl-compatible regular expressio Line 47  PCRE - Perl-compatible regular expressio
47  .ti +5n  .ti +5n
48  .B char *\fIbuffer\fP, int \fIbuffersize\fP);  .B char *\fIbuffer\fP, int \fIbuffersize\fP);
49  .PP  .PP
 .br  
50  .B int pcre_copy_substring(const char *\fIsubject\fP, int *\fIovector\fP,  .B int pcre_copy_substring(const char *\fIsubject\fP, int *\fIovector\fP,
51  .ti +5n  .ti +5n
52  .B int \fIstringcount\fP, int \fIstringnumber\fP, char *\fIbuffer\fP,  .B int \fIstringcount\fP, int \fIstringnumber\fP, char *\fIbuffer\fP,
53  .ti +5n  .ti +5n
54  .B int \fIbuffersize\fP);  .B int \fIbuffersize\fP);
55  .PP  .PP
 .br  
56  .B int pcre_get_named_substring(const pcre *\fIcode\fP,  .B int pcre_get_named_substring(const pcre *\fIcode\fP,
57  .ti +5n  .ti +5n
58  .B const char *\fIsubject\fP, int *\fIovector\fP,  .B const char *\fIsubject\fP, int *\fIovector\fP,
# Line 69  PCRE - Perl-compatible regular expressio Line 61  PCRE - Perl-compatible regular expressio
61  .ti +5n  .ti +5n
62  .B const char **\fIstringptr\fP);  .B const char **\fIstringptr\fP);
63  .PP  .PP
 .br  
64  .B int pcre_get_stringnumber(const pcre *\fIcode\fP,  .B int pcre_get_stringnumber(const pcre *\fIcode\fP,
65  .ti +5n  .ti +5n
66  .B const char *\fIname\fP);  .B const char *\fIname\fP);
67  .PP  .PP
 .br  
68  .B int pcre_get_stringtable_entries(const pcre *\fIcode\fP,  .B int pcre_get_stringtable_entries(const pcre *\fIcode\fP,
69  .ti +5n  .ti +5n
70  .B const char *\fIname\fP, char **\fIfirst\fP, char **\fIlast\fP);  .B const char *\fIname\fP, char **\fIfirst\fP, char **\fIlast\fP);
71  .PP  .PP
 .br  
72  .B int pcre_get_substring(const char *\fIsubject\fP, int *\fIovector\fP,  .B int pcre_get_substring(const char *\fIsubject\fP, int *\fIovector\fP,
73  .ti +5n  .ti +5n
74  .B int \fIstringcount\fP, int \fIstringnumber\fP,  .B int \fIstringcount\fP, int \fIstringnumber\fP,
75  .ti +5n  .ti +5n
76  .B const char **\fIstringptr\fP);  .B const char **\fIstringptr\fP);
77  .PP  .PP
 .br  
78  .B int pcre_get_substring_list(const char *\fIsubject\fP,  .B int pcre_get_substring_list(const char *\fIsubject\fP,
79  .ti +5n  .ti +5n
80  .B int *\fIovector\fP, int \fIstringcount\fP, "const char ***\fIlistptr\fP);"  .B int *\fIovector\fP, int \fIstringcount\fP, "const char ***\fIlistptr\fP);"
81  .PP  .PP
 .br  
82  .B void pcre_free_substring(const char *\fIstringptr\fP);  .B void pcre_free_substring(const char *\fIstringptr\fP);
83  .PP  .PP
 .br  
84  .B void pcre_free_substring_list(const char **\fIstringptr\fP);  .B void pcre_free_substring_list(const char **\fIstringptr\fP);
85  .PP  .PP
 .br  
86  .B const unsigned char *pcre_maketables(void);  .B const unsigned char *pcre_maketables(void);
87  .PP  .PP
 .br  
88  .B int pcre_fullinfo(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"  .B int pcre_fullinfo(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"
89  .ti +5n  .ti +5n
90  .B int \fIwhat\fP, void *\fIwhere\fP);  .B int \fIwhat\fP, void *\fIwhere\fP);
91  .PP  .PP
 .br  
92  .B int pcre_info(const pcre *\fIcode\fP, int *\fIoptptr\fP, int  .B int pcre_info(const pcre *\fIcode\fP, int *\fIoptptr\fP, int
93  .B *\fIfirstcharptr\fP);  .B *\fIfirstcharptr\fP);
94  .PP  .PP
 .br  
95  .B int pcre_refcount(pcre *\fIcode\fP, int \fIadjust\fP);  .B int pcre_refcount(pcre *\fIcode\fP, int \fIadjust\fP);
96  .PP  .PP
 .br  
97  .B int pcre_config(int \fIwhat\fP, void *\fIwhere\fP);  .B int pcre_config(int \fIwhat\fP, void *\fIwhere\fP);
98  .PP  .PP
 .br  
99  .B char *pcre_version(void);  .B char *pcre_version(void);
100  .PP  .PP
 .br  
101  .B void *(*pcre_malloc)(size_t);  .B void *(*pcre_malloc)(size_t);
102  .PP  .PP
 .br  
103  .B void (*pcre_free)(void *);  .B void (*pcre_free)(void *);
104  .PP  .PP
 .br  
105  .B void *(*pcre_stack_malloc)(size_t);  .B void *(*pcre_stack_malloc)(size_t);
106  .PP  .PP
 .br  
107  .B void (*pcre_stack_free)(void *);  .B void (*pcre_stack_free)(void *);
108  .PP  .PP
 .br  
109  .B int (*pcre_callout)(pcre_callout_block *);  .B int (*pcre_callout)(pcre_callout_block *);
110  .  .
111  .  .
# Line 246  documentation. Line 221  documentation.
221  .SH NEWLINES  .SH NEWLINES
222  .rs  .rs
223  .sp  .sp
224  PCRE supports four different conventions for indicating line breaks in  PCRE supports five different conventions for indicating line breaks in
225  strings: a single CR (carriage return) character, a single LF (linefeed)  strings: a single CR (carriage return) character, a single LF (linefeed)
226  character, the two-character sequence CRLF, or any Unicode newline sequence.  character, the two-character sequence CRLF, any of the three preceding, or any
227  The Unicode newline sequences are the three just mentioned, plus the single  Unicode newline sequence. The Unicode newline sequences are the three just
228  characters VT (vertical tab, U+000B), FF (formfeed, U+000C), NEL (next line,  mentioned, plus the single characters VT (vertical tab, U+000B), FF (formfeed,
229  U+0085), LS (line separator, U+2028), and PS (paragraph separator, U+2029).  U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and PS
230    (paragraph separator, U+2029).
231  .P  .P
232  Each of the first three conventions is used by at least one operating system as  Each of the first three conventions is used by at least one operating system as
233  its standard newline sequence. When PCRE is built, a default can be specified.  its standard newline sequence. When PCRE is built, a default can be specified.
# Line 322  properties is available; otherwise it is Line 298  properties is available; otherwise it is
298  .sp  .sp
299  The output is an integer whose value specifies the default character sequence  The output is an integer whose value specifies the default character sequence
300  that is recognized as meaning "newline". The four values that are supported  that is recognized as meaning "newline". The four values that are supported
301  are: 10 for LF, 13 for CR, 3338 for CRLF, and -1 for ANY. The default should  are: 10 for LF, 13 for CR, 3338 for CRLF, -2 for ANYCRLF, and -1 for ANY. The
302  normally be the standard sequence for your operating system.  default should normally be the standard sequence for your operating system.
303  .sp  .sp
304    PCRE_CONFIG_LINK_SIZE    PCRE_CONFIG_LINK_SIZE
305  .sp  .sp
# Line 557  occurrences of ^ or $ in a pattern, sett Line 533  occurrences of ^ or $ in a pattern, sett
533    PCRE_NEWLINE_CR    PCRE_NEWLINE_CR
534    PCRE_NEWLINE_LF    PCRE_NEWLINE_LF
535    PCRE_NEWLINE_CRLF    PCRE_NEWLINE_CRLF
536      PCRE_NEWLINE_ANYCRLF
537    PCRE_NEWLINE_ANY    PCRE_NEWLINE_ANY
538  .sp  .sp
539  These options override the default newline definition that was chosen when PCRE  These options override the default newline definition that was chosen when PCRE
540  was built. Setting the first or the second specifies that a newline is  was built. Setting the first or the second specifies that a newline is
541  indicated by a single character (CR or LF, respectively). Setting  indicated by a single character (CR or LF, respectively). Setting
542  PCRE_NEWLINE_CRLF specifies that a newline is indicated by the two-character  PCRE_NEWLINE_CRLF specifies that a newline is indicated by the two-character
543  CRLF sequence. Setting PCRE_NEWLINE_ANY specifies that any Unicode newline  CRLF sequence. Setting PCRE_NEWLINE_ANYCRLF specifies that any of the three
544  sequence should be recognized. The Unicode newline sequences are the three just  preceding sequences should be recognized. Setting PCRE_NEWLINE_ANY specifies
545  mentioned, plus the single characters VT (vertical tab, U+000B), FF (formfeed,  that any Unicode newline sequence should be recognized. The Unicode newline
546  U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and PS  sequences are the three just mentioned, plus the single characters VT (vertical
547  (paragraph separator, U+2029). The last two are recognized only in UTF-8 mode.  tab, U+000B), FF (formfeed, U+000C), NEL (next line, U+0085), LS (line
548    separator, U+2028), and PS (paragraph separator, U+2029). The last two are
549    recognized only in UTF-8 mode.
550  .P  .P
551  The newline setting in the options word uses three bits that are treated  The newline setting in the options word uses three bits that are treated
552  as a number, giving eight possibilities. Currently only five are used (default  as a number, giving eight possibilities. Currently only six are used (default
553  plus the four values above). This means that if you set more than one newline  plus the five values above). This means that if you set more than one newline
554  option, the combination may or may not be sensible. For example,  option, the combination may or may not be sensible. For example,
555  PCRE_NEWLINE_CR with PCRE_NEWLINE_LF is equivalent to PCRE_NEWLINE_CRLF, but  PCRE_NEWLINE_CR with PCRE_NEWLINE_LF is equivalent to PCRE_NEWLINE_CRLF, but
556  other combinations yield unused numbers and cause an error.  other combinations may yield unused numbers and cause an error.
557  .P  .P
558  The only time that a line break is specially recognized when compiling a  The only time that a line break is specially recognized when compiling a
559  pattern is if PCRE_EXTENDED is set, and an unescaped # outside a character  pattern is if PCRE_EXTENDED is set, and an unescaped # outside a character
# Line 754  bytes is created. Line 733  bytes is created.
733  .SH "LOCALE SUPPORT"  .SH "LOCALE SUPPORT"
734  .rs  .rs
735  .sp  .sp
736  PCRE handles caseless matching, and determines whether characters are letters  PCRE handles caseless matching, and determines whether characters are letters,
737  digits, or whatever, by reference to a set of tables, indexed by character  digits, or whatever, by reference to a set of tables, indexed by character
738  value. When running in UTF-8 mode, this applies only to characters with codes  value. When running in UTF-8 mode, this applies only to characters with codes
739  less than 128. Higher-valued codes never match escapes such as \ew or \ed, but  less than 128. Higher-valued codes never match escapes such as \ew or \ed, but
740  can be tested with \ep if PCRE is built with Unicode character property  can be tested with \ep if PCRE is built with Unicode character property
741  support. The use of locales with Unicode is discouraged.  support. The use of locales with Unicode is discouraged. If you are handling
742  .P  characters with codes greater than 128, you should either use UTF-8 and
743  An internal set of tables is created in the default C locale when PCRE is  Unicode, or use locales, but not try to mix the two.
744  built. This is used when the final argument of \fBpcre_compile()\fP is NULL,  .P
745  and is sufficient for many applications. An alternative set of tables can,  PCRE contains an internal set of tables that are used when the final argument
746  however, be supplied. These may be created in a different locale from the  of \fBpcre_compile()\fP is NULL. These are sufficient for many applications.
747  default. As more and more applications change to using Unicode, the need for  Normally, the internal tables recognize only ASCII characters. However, when
748  this locale support is expected to die away.  PCRE is built, it is possible to cause the internal tables to be rebuilt in the
749    default "C" locale of the local system, which may cause them to be different.
750    .P
751    The internal tables can always be overridden by tables supplied by the
752    application that calls PCRE. These may be created in a different locale from
753    the default. As more and more applications change to using Unicode, the need
754    for this locale support is expected to die away.
755  .P  .P
756  External tables are built by calling the \fBpcre_maketables()\fP function,  External tables are built by calling the \fBpcre_maketables()\fP function,
757  which has no arguments, in the relevant locale. The result can then be passed  which has no arguments, in the relevant locale. The result can then be passed
# Line 779  the following code could be used: Line 764  the following code could be used:
764    tables = pcre_maketables();    tables = pcre_maketables();
765    re = pcre_compile(..., tables);    re = pcre_compile(..., tables);
766  .sp  .sp
767    The locale name "fr_FR" is used on Linux and other Unix-like systems; if you
768    are using Windows, the name for the French locale is "french".
769    .P
770  When \fBpcre_maketables()\fP runs, the tables are built in memory that is  When \fBpcre_maketables()\fP runs, the tables are built in memory that is
771  obtained via \fBpcre_malloc\fP. It is the caller's responsibility to ensure  obtained via \fBpcre_malloc\fP. It is the caller's responsibility to ensure
772  that the memory containing the tables remains available for as long as it is  that the memory containing the tables remains available for as long as it is
# Line 1166  matching time. Line 1154  matching time.
1154    PCRE_NEWLINE_CR    PCRE_NEWLINE_CR
1155    PCRE_NEWLINE_LF    PCRE_NEWLINE_LF
1156    PCRE_NEWLINE_CRLF    PCRE_NEWLINE_CRLF
1157      PCRE_NEWLINE_ANYCRLF
1158    PCRE_NEWLINE_ANY    PCRE_NEWLINE_ANY
1159  .sp  .sp
1160  These options override the newline definition that was chosen or defaulted when  These options override the newline definition that was chosen or defaulted when
# Line 1173  the pattern was compiled. For details, s Line 1162  the pattern was compiled. For details, s
1162  \fBpcre_compile()\fP above. During matching, the newline choice affects the  \fBpcre_compile()\fP above. During matching, the newline choice affects the
1163  behaviour of the dot, circumflex, and dollar metacharacters. It may also alter  behaviour of the dot, circumflex, and dollar metacharacters. It may also alter
1164  the way the match position is advanced after a match failure for an unanchored  the way the match position is advanced after a match failure for an unanchored
1165  pattern. When PCRE_NEWLINE_CRLF or PCRE_NEWLINE_ANY is set, and a match attempt  pattern. When PCRE_NEWLINE_CRLF, PCRE_NEWLINE_ANYCRLF, or PCRE_NEWLINE_ANY is
1166  fails when the current position is at a CRLF sequence, the match position is  set, and a match attempt fails when the current position is at a CRLF sequence,
1167  advanced by two characters instead of one, in other words, to after the CRLF.  the match position is advanced by two characters instead of one, in other
1168    words, to after the CRLF.
1169  .sp  .sp
1170    PCRE_NOTBOL    PCRE_NOTBOL
1171  .sp  .sp
# Line 1476  Error numbers -16 to -20 are not used by Line 1466  Error numbers -16 to -20 are not used by
1466  .ti +5n  .ti +5n
1467  .B int \fIbuffersize\fP);  .B int \fIbuffersize\fP);
1468  .PP  .PP
 .br  
1469  .B int pcre_get_substring(const char *\fIsubject\fP, int *\fIovector\fP,  .B int pcre_get_substring(const char *\fIsubject\fP, int *\fIovector\fP,
1470  .ti +5n  .ti +5n
1471  .B int \fIstringcount\fP, int \fIstringnumber\fP,  .B int \fIstringcount\fP, int \fIstringnumber\fP,
1472  .ti +5n  .ti +5n
1473  .B const char **\fIstringptr\fP);  .B const char **\fIstringptr\fP);
1474  .PP  .PP
 .br  
1475  .B int pcre_get_substring_list(const char *\fIsubject\fP,  .B int pcre_get_substring_list(const char *\fIsubject\fP,
1476  .ti +5n  .ti +5n
1477  .B int *\fIovector\fP, int \fIstringcount\fP, "const char ***\fIlistptr\fP);"  .B int *\fIovector\fP, int \fIstringcount\fP, "const char ***\fIlistptr\fP);"
# Line 1569  provided. Line 1557  provided.
1557  .ti +5n  .ti +5n
1558  .B const char *\fIname\fP);  .B const char *\fIname\fP);
1559  .PP  .PP
 .br  
1560  .B int pcre_copy_named_substring(const pcre *\fIcode\fP,  .B int pcre_copy_named_substring(const pcre *\fIcode\fP,
1561  .ti +5n  .ti +5n
1562  .B const char *\fIsubject\fP, int *\fIovector\fP,  .B const char *\fIsubject\fP, int *\fIovector\fP,
# Line 1578  provided. Line 1565  provided.
1565  .ti +5n  .ti +5n
1566  .B char *\fIbuffer\fP, int \fIbuffersize\fP);  .B char *\fIbuffer\fP, int \fIbuffersize\fP);
1567  .PP  .PP
 .br  
1568  .B int pcre_get_named_substring(const pcre *\fIcode\fP,  .B int pcre_get_named_substring(const pcre *\fIcode\fP,
1569  .ti +5n  .ti +5n
1570  .B const char *\fIsubject\fP, int *\fIovector\fP,  .B const char *\fIsubject\fP, int *\fIovector\fP,
# Line 1614  pattern. This is needed in order to gain Line 1600  pattern. This is needed in order to gain
1600  translation table.  translation table.
1601  .P  .P
1602  These functions call \fBpcre_get_stringnumber()\fP, and if it succeeds, they  These functions call \fBpcre_get_stringnumber()\fP, and if it succeeds, they
1603  then call \fIpcre_copy_substring()\fP or \fIpcre_get_substring()\fP, as  then call \fBpcre_copy_substring()\fP or \fBpcre_get_substring()\fP, as
1604  appropriate.  appropriate. \fBNOTE:\fP If PCRE_DUPNAMES is set and there are duplicate names,
1605    the behaviour may not be what you want (see the next section).
1606  .  .
1607  .  .
1608  .SH "DUPLICATE SUBPATTERN NAMES"  .SH "DUPLICATE SUBPATTERN NAMES"
# Line 1846  extremely rare, as a vector of size 1000 Line 1833  extremely rare, as a vector of size 1000
1833  \fBpcrebuild\fP(3), \fBpcrecallout\fP(3), \fBpcrecpp(3)\fP(3),  \fBpcrebuild\fP(3), \fBpcrecallout\fP(3), \fBpcrecpp(3)\fP(3),
1834  \fBpcrematching\fP(3), \fBpcrepartial\fP(3), \fBpcreposix\fP(3),  \fBpcrematching\fP(3), \fBpcrepartial\fP(3), \fBpcreposix\fP(3),
1835  \fBpcreprecompile\fP(3), \fBpcresample\fP(3), \fBpcrestack\fP(3).  \fBpcreprecompile\fP(3), \fBpcresample\fP(3), \fBpcrestack\fP(3).
1836  .P  .
1837  .in 0  .
1838  Last updated: 30 November 2006  .SH AUTHOR
1839  .br  .rs
1840  Copyright (c) 1997-2006 University of Cambridge.  .sp
1841    .nf
1842    Philip Hazel
1843    University Computing Service
1844    Cambridge CB2 3QH, England.
1845    .fi
1846    .
1847    .
1848    .SH REVISION
1849    .rs
1850    .sp
1851    .nf
1852    Last updated: 16 April 2007
1853    Copyright (c) 1997-2007 University of Cambridge.
1854    .fi

Legend:
Removed from v.96  
changed lines
  Added in v.149

  ViewVC Help
Powered by ViewVC 1.1.5