/[pcre]/code/tags/pcre-4.1/README
ViewVC logotype

Diff of /code/tags/pcre-4.1/README

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

revision 33 by nigel, Sat Feb 24 21:39:01 2007 UTC revision 35 by nigel, Sat Feb 24 21:39:05 2007 UTC
# Line 16  README file for PCRE (Perl-compatible re Line 16  README file for PCRE (Perl-compatible re
16  * possible to pass over a pointer to character tables built in the current    *  * possible to pass over a pointer to character tables built in the current    *
17  * locale by pcre_maketables(). To use the default tables, this new arguement  *  * locale by pcre_maketables(). To use the default tables, this new arguement  *
18  * should be passed as NULL.                                                   *  * should be passed as NULL.                                                   *
19    *                                                                             *
20    *           IMPORTANT FOR THOSE UPGRADING FROM VERSION 2.05                   *
21    *                                                                             *
22    * Yet another (and again I hope this really is the last) change has been made *
23    * to the API for the pcre_exec() function. An additional argument has been    *
24    * added to make it possible to start the match other than at the start of the *
25    * subject string. This is important if there are lookbehinds. The new man     *
26    * page has the details, but you just want to convert existing programs, all   *
27    * you need to do is to stick in a new fifth argument to pcre_exec(), with a   *
28    * value of zero. For example, change                                          *
29    *                                                                             *
30    *   pcre_exec(pattern, extra, subject, length, options, ovec, ovecsize)       *
31    * to                                                                          *
32    *   pcre_exec(pattern, extra, subject, length, 0, options, ovec, ovecsize)    *
33  *******************************************************************************  *******************************************************************************
34    
35    
36  The distribution should contain the following files:  The distribution should contain the following files:
37    
38    ChangeLog         log of changes to the code    ChangeLog         log of changes to the code
# Line 45  The distribution should contain the foll Line 60  The distribution should contain the foll
60    testinput2        test data for error messages and non-Perl things    testinput2        test data for error messages and non-Perl things
61    testinput3        test data, compatible with Perl 5.005    testinput3        test data, compatible with Perl 5.005
62    testinput4        test data for locale-specific tests    testinput4        test data for locale-specific tests
63    testoutput1       test results corresponding to testinput    testoutput1       test results corresponding to testinput1
64    testoutput2       test results corresponding to testinput2    testoutput2       test results corresponding to testinput2
65    testoutput3       test results corresponding to testinput3    testoutput3       test results corresponding to testinput3
66    testoutput4       test results corresponding to testinput4    testoutput4       test results corresponding to testinput4
# Line 112  Character tables Line 127  Character tables
127    
128  PCRE uses four tables for manipulating and identifying characters. The final  PCRE uses four tables for manipulating and identifying characters. The final
129  argument of the pcre_compile() function is a pointer to a block of memory  argument of the pcre_compile() function is a pointer to a block of memory
130  containing the concatenated tables. A call to pcre_maketables() is used to  containing the concatenated tables. A call to pcre_maketables() can be used to
131  generate a set of tables in the current locale. However, if the final argument  generate a set of tables in the current locale. If the final argument for
132  is passed as NULL, a set of default tables that is built into the binary is  pcre_compile() is passed as NULL, a set of default tables that is built into
133  used.  the binary is used.
134    
135  The source file called chartables.c contains the default set of tables. This is  The source file called chartables.c contains the default set of tables. This is
136  not supplied in the distribution, but is built by the program dftables  not supplied in the distribution, but is built by the program dftables
137  (compiled from dftables.c), which uses the ANSI C character handling functions  (compiled from dftables.c), which uses the ANSI C character handling functions
138  such as isalnum(), isalpha(), isupper(), islower(), etc. to build the table  such as isalnum(), isalpha(), isupper(), islower(), etc. to build the table
139  sources. This means that the default C locale set your system will control the  sources. This means that the default C locale which is set for your system will
140  contents of the tables. You can change the default tables by editing  control the contents of these default tables. You can change the default tables
141  chartables.c and then re-building PCRE. If you do this, you should probably  by editing chartables.c and then re-building PCRE. If you do this, you should
142  also edit Makefile to ensure that the file doesn't ever get re-generated.  probably also edit Makefile to ensure that the file doesn't ever get
143    re-generated.
144    
145  The first two 256-byte tables provide lower casing and case flipping functions,  The first two 256-byte tables provide lower casing and case flipping functions,
146  respectively. The next table consists of three 32-byte bit maps which identify  respectively. The next table consists of three 32-byte bit maps which identify
# Line 178  example, Line 194  example,
194    
195    /abc/\    /abc/\
196    
197  then a backslash is added to the end of the pattern. This provides a way of  then a backslash is added to the end of the pattern. This is done to provide a
198  testing the error condition that arises if a pattern finishes with a backslash,  way of testing the error condition that arises if a pattern finishes with a
199  because  backslash, because
200    
201    /abc\/    /abc\/
202    
# Line 188  is interpreted as the first line of a pa Line 204  is interpreted as the first line of a pa
204  pcretest to read the next line as a continuation of the regular expression.  pcretest to read the next line as a continuation of the regular expression.
205    
206  The pattern may be followed by i, m, s, or x to set the PCRE_CASELESS,  The pattern may be followed by i, m, s, or x to set the PCRE_CASELESS,
207  PCRE_MULTILINE, PCRE_DOTALL, or PCRE_EXTENDED options, respectively. These  PCRE_MULTILINE, PCRE_DOTALL, or PCRE_EXTENDED options, respectively. For
208  options have the same effect as they do in Perl.  example:
209    
210      /caseless/i
211    
212  There are also some upper case options that do not match Perl options: /A, /E,  These modifier letters have the same effect as they do in Perl. There are
213  and /X set PCRE_ANCHORED, PCRE_DOLLAR_ENDONLY, and PCRE_EXTRA respectively.  others which set PCRE options that do not correspond to anything in Perl: /A,
214    /E, and /X set PCRE_ANCHORED, PCRE_DOLLAR_ENDONLY, and PCRE_EXTRA respectively.
215    
216    Searching for all possible matches within each subject string can be requested
217    by the /g or /G modifier. The /g modifier behaves similarly to the way it does
218    in Perl. After finding a match, PCRE is called again to search the remainder of
219    the subject string. The difference between /g and /G is that the former uses
220    the start_offset argument to pcre_exec() to start searching at a new point
221    within the entire string, whereas the latter passes over a shortened substring.
222    This makes a difference to the matching process if the pattern begins with a
223    lookbehind assertion (including \b or \B).
224    
225    There are a number of other modifiers for controlling the way pcretest
226    operates.
227    
228    The /+ modifier requests that as well as outputting the substring that matched
229    the entire pattern, pcretest should in addition output the remainder of the
230    subject string. This is useful for tests where the subject contains multiple
231    copies of the same substring.
232    
233  The /L option must be followed directly by the name of a locale, for example,  The /L modifier must be followed directly by the name of a locale, for example,
234    
235    /pattern/Lfr    /pattern/Lfr
236    
237  For this reason, it must be the last option letter. The given locale is set,  For this reason, it must be the last modifier letter. The given locale is set,
238  pcre_maketables() is called to build a set of character tables for the locale,  pcre_maketables() is called to build a set of character tables for the locale,
239  and this is then passed to pcre_compile() when compiling the regular  and this is then passed to pcre_compile() when compiling the regular
240  expression. Without an /L option, NULL is passed as the tables pointer; that  expression. Without an /L modifier, NULL is passed as the tables pointer; that
241  is, /L applies only to the expression on which it appears.  is, /L applies only to the expression on which it appears.
242    
243  The /I option requests that pcretest output information about the compiled  The /I modifier requests that pcretest output information about the compiled
244  expression (whether it is anchored, has a fixed first character, and so on). It  expression (whether it is anchored, has a fixed first character, and so on). It
245  does this by calling pcre_info() after compiling an expression, and outputting  does this by calling pcre_info() after compiling an expression, and outputting
246  the information it gets back. If the pattern is studied, the results of that  the information it gets back. If the pattern is studied, the results of that
247  are also output.  are also output.
248    
249  The /D option is a PCRE debugging feature, which also assumes /I. It causes the  The /D modifier is a PCRE debugging feature, which also assumes /I. It causes
250  internal form of compiled regular expressions to be output after compilation.  the internal form of compiled regular expressions to be output after
251    compilation.
252    
253  The /S option causes pcre_study() to be called after the expression has been  The /S modifier causes pcre_study() to be called after the expression has been
254  compiled, and the results used when the expression is matched.  compiled, and the results used when the expression is matched.
255    
256  The /M option causes information about the size of memory block used to hold  The /M modifier causes information about the size of memory block used to hold
257  the compile pattern to be output.  the compile pattern to be output.
258    
259  Finally, the /P option causes pcretest to call PCRE via the POSIX wrapper API  Finally, the /P modifier causes pcretest to call PCRE via the POSIX wrapper API
260  rather than its native API. When this is done, all other options except /i and  rather than its native API. When this is done, all other modifiers except /i,
261  /m are ignored. REG_ICASE is set if /i is present, and REG_NEWLINE is set if /m  /m, and /+ are ignored. REG_ICASE is set if /i is present, and REG_NEWLINE is
262  is present. The wrapper functions force PCRE_DOLLAR_ENDONLY always, and  set if /m is present. The wrapper functions force PCRE_DOLLAR_ENDONLY always,
263  PCRE_DOTALL unless REG_NEWLINE is set.  and PCRE_DOTALL unless REG_NEWLINE is set.
264    
265  Before each data line is passed to pcre_exec(), leading and trailing whitespace  Before each data line is passed to pcre_exec(), leading and trailing whitespace
266  is removed, and it is then scanned for \ escapes. The following are recognized:  is removed, and it is then scanned for \ escapes. The following are recognized:
# Line 263  pcre_exec() returns, starting with numbe Line 300  pcre_exec() returns, starting with numbe
300  whole pattern. Here is an example of an interactive pcretest run.  whole pattern. Here is an example of an interactive pcretest run.
301    
302    $ pcretest    $ pcretest
303    Testing Perl-Compatible Regular Expressions    PCRE version 2.06 08-Jun-1999
   PCRE version 0.90 08-Sep-1997  
304    
305      re> /^abc(\d+)/      re> /^abc(\d+)/
306    data> abc123    data> abc123
307      0: abc123     0: abc123
308      1: 123     1: 123
309    data> xyz    data> xyz
310    No match    No match
311    
312    If the strings contain any non-printing characters, they are output as \0x
313    escapes. If the pattern has the /+ modifier, then the output for substring 0 is
314    followed by the the rest of the subject string, identified by "0+" like this:
315    
316        re> /cat/+
317      data> cataract
318       0: cat
319       0+ aract
320    
321    If the pattern has the /g or /G modifier, the results of successive matching
322    attempts are output in sequence, like this:
323    
324        re> /\Bi(\w\w)/g
325      data> Mississippi
326       0: iss
327       1: ss
328       0: iss
329       1: ss
330       0: ipp
331       1: pp
332    
333    "No match" is output only if the first match attempt fails.
334    
335  If any of \C, \G, or \L are present in a data line that is successfully  If any of \C, \G, or \L are present in a data line that is successfully
336  matched, the substrings extracted by the convenience functions are output with  matched, the substrings extracted by the convenience functions are output with
337  C, G, or L after the string number instead of a colon. This is in addition to  C, G, or L after the string number instead of a colon. This is in addition to
# Line 313  The perltest program Line 372  The perltest program
372    
373  The perltest program tests Perl's regular expressions; it has the same  The perltest program tests Perl's regular expressions; it has the same
374  specification as pcretest, and so can be given identical input, except that  specification as pcretest, and so can be given identical input, except that
375  input patterns can be followed only by Perl's lower case options. The contents  input patterns can be followed only by Perl's lower case modifiers. The
376  of testinput1 and testinput3 meet this condition.  contents of testinput1 and testinput3 meet this condition.
377    
378  The data lines are processed as Perl strings, so if they contain $ or @  The data lines are processed as Perl strings, so if they contain $ or @
379  characters, these have to be escaped. For this reason, all such characters in  characters, these have to be escaped. For this reason, all such characters in
380  the testinput file are escaped so that it can be used for perltest as well as  testinput1 and testinput3 are escaped so that they can be used for perltest as
381  for pcretest, and the special upper case options such as /A that pcretest  well as for pcretest, and the special upper case modifiers such as /A that
382  recognizes are not used in this file. The output should be identical, apart  pcretest recognizes are not used in these files. The output should be
383  from the initial identifying banner.  identical, apart from the initial identifying banner.
384    
385  The testinput2 and testinput4 files are not suitable for feeding to Perltest,  The testinput2 and testinput4 files are not suitable for feeding to perltest,
386  since they do make use of the special upper case options and escapes that  since they do make use of the special upper case modifiers and escapes that
387  pcretest uses to test some features of PCRE. The first of these files also  pcretest uses to test some features of PCRE. The first of these files also
388  contains malformed regular expressions, in order to check that PCRE diagnoses  contains malformed regular expressions, in order to check that PCRE diagnoses
389  them correctly.  them correctly.
390    
391  Philip Hazel <ph10@cam.ac.uk>  Philip Hazel <ph10@cam.ac.uk>
392  April 1999  June 1999

Legend:
Removed from v.33  
changed lines
  Added in v.35

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12