/[pcre]/code/trunk/doc/pcretest.1
ViewVC logotype

Contents of /code/trunk/doc/pcretest.1

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1404 - (show annotations)
Tue Nov 19 15:36:57 2013 UTC (5 years, 9 months ago) by ph10
File size: 48590 byte(s)
Source tidies for 8.34-RC1.
1 .TH PCRETEST 1 "12 November 2013" "PCRE 8.34"
2 .SH NAME
3 pcretest - a program for testing Perl-compatible regular expressions.
4 .SH SYNOPSIS
5 .rs
6 .sp
7 .B pcretest "[options] [input file [output file]]"
8 .sp
9 \fBpcretest\fP was written as a test program for the PCRE regular expression
10 library itself, but it can also be used for experimenting with regular
11 expressions. This document describes the features of the test program; for
12 details of the regular expressions themselves, see the
13 .\" HREF
14 \fBpcrepattern\fP
15 .\"
16 documentation. For details of the PCRE library function calls and their
17 options, see the
18 .\" HREF
19 \fBpcreapi\fP
20 .\"
21 ,
22 .\" HREF
23 \fBpcre16\fP
24 and
25 .\" HREF
26 \fBpcre32\fP
27 .\"
28 documentation.
29 .P
30 The input for \fBpcretest\fP is a sequence of regular expression patterns and
31 strings to be matched, as described below. The output shows the result of each
32 match. Options on the command line and the patterns control PCRE options and
33 exactly what is output.
34 .P
35 As PCRE has evolved, it has acquired many different features, and as a result,
36 \fBpcretest\fP now has rather a lot of obscure options for testing every
37 possible feature. Some of these options are specifically designed for use in
38 conjunction with the test script and data files that are distributed as part of
39 PCRE, and are unlikely to be of use otherwise. They are all documented here,
40 but without much justification.
41 .
42 .
43 .SH "INPUT DATA FORMAT"
44 .rs
45 .sp
46 Input to \fBpcretest\fP is processed line by line, either by calling the C
47 library's \fBfgets()\fP function, or via the \fBlibreadline\fP library (see
48 below). In Unix-like environments, \fBfgets()\fP treats any bytes other than
49 newline as data characters. However, in some Windows environments character 26
50 (hex 1A) causes an immediate end of file, and no further data is read. For
51 maximum portability, therefore, it is safest to use only ASCII characters in
52 \fBpcretest\fP input files.
53 .
54 .
55 .SH "PCRE's 8-BIT, 16-BIT AND 32-BIT LIBRARIES"
56 .rs
57 .sp
58 From release 8.30, two separate PCRE libraries can be built. The original one
59 supports 8-bit character strings, whereas the newer 16-bit library supports
60 character strings encoded in 16-bit units. From release 8.32, a third library
61 can be built, supporting character strings encoded in 32-bit units. The
62 \fBpcretest\fP program can be used to test all three libraries. However, it is
63 itself still an 8-bit program, reading 8-bit input and writing 8-bit output.
64 When testing the 16-bit or 32-bit library, the patterns and data strings are
65 converted to 16- or 32-bit format before being passed to the PCRE library
66 functions. Results are converted to 8-bit for output.
67 .P
68 References to functions and structures of the form \fBpcre[16|32]_xx\fP below
69 mean "\fBpcre_xx\fP when using the 8-bit library, \fBpcre16_xx\fP when using
70 the 16-bit library, or \fBpcre32_xx\fP when using the 32-bit library".
71 .
72 .
73 .SH "COMMAND LINE OPTIONS"
74 .rs
75 .TP 10
76 \fB-8\fP
77 If both the 8-bit library has been built, this option causes the 8-bit library
78 to be used (which is the default); if the 8-bit library has not been built,
79 this option causes an error.
80 .TP 10
81 \fB-16\fP
82 If both the 8-bit or the 32-bit, and the 16-bit libraries have been built, this
83 option causes the 16-bit library to be used. If only the 16-bit library has been
84 built, this is the default (so has no effect). If only the 8-bit or the 32-bit
85 library has been built, this option causes an error.
86 .TP 10
87 \fB-32\fP
88 If both the 8-bit or the 16-bit, and the 32-bit libraries have been built, this
89 option causes the 32-bit library to be used. If only the 32-bit library has been
90 built, this is the default (so has no effect). If only the 8-bit or the 16-bit
91 library has been built, this option causes an error.
92 .TP 10
93 \fB-b\fP
94 Behave as if each pattern has the \fB/B\fP (show byte code) modifier; the
95 internal form is output after compilation.
96 .TP 10
97 \fB-C\fP
98 Output the version number of the PCRE library, and all available information
99 about the optional features that are included, and then exit with zero exit
100 code. All other options are ignored.
101 .TP 10
102 \fB-C\fP \fIoption\fP
103 Output information about a specific build-time option, then exit. This
104 functionality is intended for use in scripts such as \fBRunTest\fP. The
105 following options output the value and set the exit code as indicated:
106 .sp
107 ebcdic-nl the code for LF (= NL) in an EBCDIC environment:
108 0x15 or 0x25
109 0 if used in an ASCII environment
110 exit code is always 0
111 linksize the configured internal link size (2, 3, or 4)
112 exit code is set to the link size
113 newline the default newline setting:
114 CR, LF, CRLF, ANYCRLF, or ANY
115 exit code is always 0
116 .sp
117 The following options output 1 for true or 0 for false, and set the exit code
118 to the same value:
119 .sp
120 ebcdic compiled for an EBCDIC environment
121 jit just-in-time support is available
122 pcre16 the 16-bit library was built
123 pcre32 the 32-bit library was built
124 pcre8 the 8-bit library was built
125 ucp Unicode property support is available
126 utf UTF-8 and/or UTF-16 and/or UTF-32 support
127 is available
128 .sp
129 If an unknown option is given, an error message is output; the exit code is 0.
130 .TP 10
131 \fB-d\fP
132 Behave as if each pattern has the \fB/D\fP (debug) modifier; the internal
133 form and information about the compiled pattern is output after compilation;
134 \fB-d\fP is equivalent to \fB-b -i\fP.
135 .TP 10
136 \fB-dfa\fP
137 Behave as if each data line contains the \eD escape sequence; this causes the
138 alternative matching function, \fBpcre[16|32]_dfa_exec()\fP, to be used instead
139 of the standard \fBpcre[16|32]_exec()\fP function (more detail is given below).
140 .TP 10
141 \fB-help\fP
142 Output a brief summary these options and then exit.
143 .TP 10
144 \fB-i\fP
145 Behave as if each pattern has the \fB/I\fP modifier; information about the
146 compiled pattern is given after compilation.
147 .TP 10
148 \fB-M\fP
149 Behave as if each data line contains the \eM escape sequence; this causes
150 PCRE to discover the minimum MATCH_LIMIT and MATCH_LIMIT_RECURSION settings by
151 calling \fBpcre[16|32]_exec()\fP repeatedly with different limits.
152 .TP 10
153 \fB-m\fP
154 Output the size of each compiled pattern after it has been compiled. This is
155 equivalent to adding \fB/M\fP to each regular expression. The size is given in
156 bytes for both libraries.
157 .TP 10
158 \fB-O\fP
159 Behave as if each pattern has the \fB/O\fP modifier, that is disable
160 auto-possessification for all patterns.
161 .TP 10
162 \fB-o\fP \fIosize\fP
163 Set the number of elements in the output vector that is used when calling
164 \fBpcre[16|32]_exec()\fP or \fBpcre[16|32]_dfa_exec()\fP to be \fIosize\fP. The
165 default value is 45, which is enough for 14 capturing subexpressions for
166 \fBpcre[16|32]_exec()\fP or 22 different matches for
167 \fBpcre[16|32]_dfa_exec()\fP.
168 The vector size can be changed for individual matching calls by including \eO
169 in the data line (see below).
170 .TP 10
171 \fB-p\fP
172 Behave as if each pattern has the \fB/P\fP modifier; the POSIX wrapper API is
173 used to call PCRE. None of the other options has any effect when \fB-p\fP is
174 set. This option can be used only with the 8-bit library.
175 .TP 10
176 \fB-q\fP
177 Do not output the version number of \fBpcretest\fP at the start of execution.
178 .TP 10
179 \fB-S\fP \fIsize\fP
180 On Unix-like systems, set the size of the run-time stack to \fIsize\fP
181 megabytes.
182 .TP 10
183 \fB-s\fP or \fB-s+\fP
184 Behave as if each pattern has the \fB/S\fP modifier; in other words, force each
185 pattern to be studied. If \fB-s+\fP is used, all the JIT compile options are
186 passed to \fBpcre[16|32]_study()\fP, causing just-in-time optimization to be set
187 up if it is available, for both full and partial matching. Specific JIT compile
188 options can be selected by following \fB-s+\fP with a digit in the range 1 to
189 7, which selects the JIT compile modes as follows:
190 .sp
191 1 normal match only
192 2 soft partial match only
193 3 normal match and soft partial match
194 4 hard partial match only
195 6 soft and hard partial match
196 7 all three modes (default)
197 .sp
198 If \fB-s++\fP is used instead of \fB-s+\fP (with or without a following digit),
199 the text "(JIT)" is added to the first output line after a match or no match
200 when JIT-compiled code was actually used.
201 .sp
202 Note that there are pattern options that can override \fB-s\fP, either
203 specifying no studying at all, or suppressing JIT compilation.
204 .sp
205 If the \fB/I\fP or \fB/D\fP option is present on a pattern (requesting output
206 about the compiled pattern), information about the result of studying is not
207 included when studying is caused only by \fB-s\fP and neither \fB-i\fP nor
208 \fB-d\fP is present on the command line. This behaviour means that the output
209 from tests that are run with and without \fB-s\fP should be identical, except
210 when options that output information about the actual running of a match are
211 set.
212 .sp
213 The \fB-M\fP, \fB-t\fP, and \fB-tm\fP options, which give information about
214 resources used, are likely to produce different output with and without
215 \fB-s\fP. Output may also differ if the \fB/C\fP option is present on an
216 individual pattern. This uses callouts to trace the the matching process, and
217 this may be different between studied and non-studied patterns. If the pattern
218 contains (*MARK) items there may also be differences, for the same reason. The
219 \fB-s\fP command line option can be overridden for specific patterns that
220 should never be studied (see the \fB/S\fP pattern modifier below).
221 .TP 10
222 \fB-t\fP
223 Run each compile, study, and match many times with a timer, and output the
224 resulting times per compile, study, or match (in milliseconds). Do not set
225 \fB-m\fP with \fB-t\fP, because you will then get the size output a zillion
226 times, and the timing will be distorted. You can control the number of
227 iterations that are used for timing by following \fB-t\fP with a number (as a
228 separate item on the command line). For example, "-t 1000" iterates 1000 times.
229 The default is to iterate 500000 times.
230 .TP 10
231 \fB-tm\fP
232 This is like \fB-t\fP except that it times only the matching phase, not the
233 compile or study phases.
234 .TP 10
235 \fB-T\fP \fB-TM\fP
236 These behave like \fB-t\fP and \fB-tm\fP, but in addition, at the end of a run,
237 the total times for all compiles, studies, and matches are output.
238 .
239 .
240 .SH DESCRIPTION
241 .rs
242 .sp
243 If \fBpcretest\fP is given two filename arguments, it reads from the first and
244 writes to the second. If it is given only one filename argument, it reads from
245 that file and writes to stdout. Otherwise, it reads from stdin and writes to
246 stdout, and prompts for each line of input, using "re>" to prompt for regular
247 expressions, and "data>" to prompt for data lines.
248 .P
249 When \fBpcretest\fP is built, a configuration option can specify that it should
250 be linked with the \fBlibreadline\fP library. When this is done, if the input
251 is from a terminal, it is read using the \fBreadline()\fP function. This
252 provides line-editing and history facilities. The output from the \fB-help\fP
253 option states whether or not \fBreadline()\fP will be used.
254 .P
255 The program handles any number of sets of input on a single input file. Each
256 set starts with a regular expression, and continues with any number of data
257 lines to be matched against that pattern.
258 .P
259 Each data line is matched separately and independently. If you want to do
260 multi-line matches, you have to use the \en escape sequence (or \er or \er\en,
261 etc., depending on the newline setting) in a single line of input to encode the
262 newline sequences. There is no limit on the length of data lines; the input
263 buffer is automatically extended if it is too small.
264 .P
265 An empty line signals the end of the data lines, at which point a new regular
266 expression is read. The regular expressions are given enclosed in any
267 non-alphanumeric delimiters other than backslash, for example:
268 .sp
269 /(a|bc)x+yz/
270 .sp
271 White space before the initial delimiter is ignored. A regular expression may
272 be continued over several input lines, in which case the newline characters are
273 included within it. It is possible to include the delimiter within the pattern
274 by escaping it, for example
275 .sp
276 /abc\e/def/
277 .sp
278 If you do so, the escape and the delimiter form part of the pattern, but since
279 delimiters are always non-alphanumeric, this does not affect its interpretation.
280 If the terminating delimiter is immediately followed by a backslash, for
281 example,
282 .sp
283 /abc/\e
284 .sp
285 then a backslash is added to the end of the pattern. This is done to provide a
286 way of testing the error condition that arises if a pattern finishes with a
287 backslash, because
288 .sp
289 /abc\e/
290 .sp
291 is interpreted as the first line of a pattern that starts with "abc/", causing
292 pcretest to read the next line as a continuation of the regular expression.
293 .
294 .
295 .SH "PATTERN MODIFIERS"
296 .rs
297 .sp
298 A pattern may be followed by any number of modifiers, which are mostly single
299 characters, though some of these can be qualified by further characters.
300 Following Perl usage, these are referred to below as, for example, "the
301 \fB/i\fP modifier", even though the delimiter of the pattern need not always be
302 a slash, and no slash is used when writing modifiers. White space may appear
303 between the final pattern delimiter and the first modifier, and between the
304 modifiers themselves. For reference, here is a complete list of modifiers. They
305 fall into several groups that are described in detail in the following
306 sections.
307 .sp
308 \fB/8\fP set UTF mode
309 \fB/9\fP set PCRE_NEVER_UTF (locks out UTF mode)
310 \fB/?\fP disable UTF validity check
311 \fB/+\fP show remainder of subject after match
312 \fB/=\fP show all captures (not just those that are set)
313 .sp
314 \fB/A\fP set PCRE_ANCHORED
315 \fB/B\fP show compiled code
316 \fB/C\fP set PCRE_AUTO_CALLOUT
317 \fB/D\fP same as \fB/B\fP plus \fB/I\fP
318 \fB/E\fP set PCRE_DOLLAR_ENDONLY
319 \fB/F\fP flip byte order in compiled pattern
320 \fB/f\fP set PCRE_FIRSTLINE
321 \fB/G\fP find all matches (shorten string)
322 \fB/g\fP find all matches (use startoffset)
323 \fB/I\fP show information about pattern
324 \fB/i\fP set PCRE_CASELESS
325 \fB/J\fP set PCRE_DUPNAMES
326 \fB/K\fP show backtracking control names
327 \fB/L\fP set locale
328 \fB/M\fP show compiled memory size
329 \fB/m\fP set PCRE_MULTILINE
330 \fB/N\fP set PCRE_NO_AUTO_CAPTURE
331 \fB/O\fP set PCRE_NO_AUTO_POSSESS
332 \fB/P\fP use the POSIX wrapper
333 \fB/S\fP study the pattern after compilation
334 \fB/s\fP set PCRE_DOTALL
335 \fB/T\fP select character tables
336 \fB/U\fP set PCRE_UNGREEDY
337 \fB/W\fP set PCRE_UCP
338 \fB/X\fP set PCRE_EXTRA
339 \fB/x\fP set PCRE_EXTENDED
340 \fB/Y\fP set PCRE_NO_START_OPTIMIZE
341 \fB/Z\fP don't show lengths in \fB/B\fP output
342 .sp
343 \fB/<any>\fP set PCRE_NEWLINE_ANY
344 \fB/<anycrlf>\fP set PCRE_NEWLINE_ANYCRLF
345 \fB/<cr>\fP set PCRE_NEWLINE_CR
346 \fB/<crlf>\fP set PCRE_NEWLINE_CRLF
347 \fB/<lf>\fP set PCRE_NEWLINE_LF
348 \fB/<bsr_anycrlf>\fP set PCRE_BSR_ANYCRLF
349 \fB/<bsr_unicode>\fP set PCRE_BSR_UNICODE
350 \fB/<JS>\fP set PCRE_JAVASCRIPT_COMPAT
351 .sp
352 .
353 .
354 .SS "Perl-compatible modifiers"
355 .rs
356 .sp
357 The \fB/i\fP, \fB/m\fP, \fB/s\fP, and \fB/x\fP modifiers set the PCRE_CASELESS,
358 PCRE_MULTILINE, PCRE_DOTALL, or PCRE_EXTENDED options, respectively, when
359 \fBpcre[16|32]_compile()\fP is called. These four modifier letters have the same
360 effect as they do in Perl. For example:
361 .sp
362 /caseless/i
363 .sp
364 .
365 .
366 .SS "Modifiers for other PCRE options"
367 .rs
368 .sp
369 The following table shows additional modifiers for setting PCRE compile-time
370 options that do not correspond to anything in Perl:
371 .sp
372 \fB/8\fP PCRE_UTF8 ) when using the 8-bit
373 \fB/?\fP PCRE_NO_UTF8_CHECK ) library
374 .sp
375 \fB/8\fP PCRE_UTF16 ) when using the 16-bit
376 \fB/?\fP PCRE_NO_UTF16_CHECK ) library
377 .sp
378 \fB/8\fP PCRE_UTF32 ) when using the 32-bit
379 \fB/?\fP PCRE_NO_UTF32_CHECK ) library
380 .sp
381 \fB/9\fP PCRE_NEVER_UTF
382 \fB/A\fP PCRE_ANCHORED
383 \fB/C\fP PCRE_AUTO_CALLOUT
384 \fB/E\fP PCRE_DOLLAR_ENDONLY
385 \fB/f\fP PCRE_FIRSTLINE
386 \fB/J\fP PCRE_DUPNAMES
387 \fB/N\fP PCRE_NO_AUTO_CAPTURE
388 \fB/O\fP PCRE_NO_AUTO_POSSESS
389 \fB/U\fP PCRE_UNGREEDY
390 \fB/W\fP PCRE_UCP
391 \fB/X\fP PCRE_EXTRA
392 \fB/Y\fP PCRE_NO_START_OPTIMIZE
393 \fB/<any>\fP PCRE_NEWLINE_ANY
394 \fB/<anycrlf>\fP PCRE_NEWLINE_ANYCRLF
395 \fB/<cr>\fP PCRE_NEWLINE_CR
396 \fB/<crlf>\fP PCRE_NEWLINE_CRLF
397 \fB/<lf>\fP PCRE_NEWLINE_LF
398 \fB/<bsr_anycrlf>\fP PCRE_BSR_ANYCRLF
399 \fB/<bsr_unicode>\fP PCRE_BSR_UNICODE
400 \fB/<JS>\fP PCRE_JAVASCRIPT_COMPAT
401 .sp
402 The modifiers that are enclosed in angle brackets are literal strings as shown,
403 including the angle brackets, but the letters within can be in either case.
404 This example sets multiline matching with CRLF as the line ending sequence:
405 .sp
406 /^abc/m<CRLF>
407 .sp
408 As well as turning on the PCRE_UTF8/16/32 option, the \fB/8\fP modifier causes
409 all non-printing characters in output strings to be printed using the
410 \ex{hh...} notation. Otherwise, those less than 0x100 are output in hex without
411 the curly brackets.
412 .P
413 Full details of the PCRE options are given in the
414 .\" HREF
415 \fBpcreapi\fP
416 .\"
417 documentation.
418 .
419 .
420 .SS "Finding all matches in a string"
421 .rs
422 .sp
423 Searching for all possible matches within each subject string can be requested
424 by the \fB/g\fP or \fB/G\fP modifier. After finding a match, PCRE is called
425 again to search the remainder of the subject string. The difference between
426 \fB/g\fP and \fB/G\fP is that the former uses the \fIstartoffset\fP argument to
427 \fBpcre[16|32]_exec()\fP to start searching at a new point within the entire
428 string (which is in effect what Perl does), whereas the latter passes over a
429 shortened substring. This makes a difference to the matching process if the
430 pattern begins with a lookbehind assertion (including \eb or \eB).
431 .P
432 If any call to \fBpcre[16|32]_exec()\fP in a \fB/g\fP or \fB/G\fP sequence matches
433 an empty string, the next call is done with the PCRE_NOTEMPTY_ATSTART and
434 PCRE_ANCHORED flags set in order to search for another, non-empty, match at the
435 same point. If this second match fails, the start offset is advanced, and the
436 normal match is retried. This imitates the way Perl handles such cases when
437 using the \fB/g\fP modifier or the \fBsplit()\fP function. Normally, the start
438 offset is advanced by one character, but if the newline convention recognizes
439 CRLF as a newline, and the current character is CR followed by LF, an advance
440 of two is used.
441 .
442 .
443 .SS "Other modifiers"
444 .rs
445 .sp
446 There are yet more modifiers for controlling the way \fBpcretest\fP
447 operates.
448 .P
449 The \fB/+\fP modifier requests that as well as outputting the substring that
450 matched the entire pattern, \fBpcretest\fP should in addition output the
451 remainder of the subject string. This is useful for tests where the subject
452 contains multiple copies of the same substring. If the \fB+\fP modifier appears
453 twice, the same action is taken for captured substrings. In each case the
454 remainder is output on the following line with a plus character following the
455 capture number. Note that this modifier must not immediately follow the /S
456 modifier because /S+ and /S++ have other meanings.
457 .P
458 The \fB/=\fP modifier requests that the values of all potential captured
459 parentheses be output after a match. By default, only those up to the highest
460 one actually used in the match are output (corresponding to the return code
461 from \fBpcre[16|32]_exec()\fP). Values in the offsets vector corresponding to
462 higher numbers should be set to -1, and these are output as "<unset>". This
463 modifier gives a way of checking that this is happening.
464 .P
465 The \fB/B\fP modifier is a debugging feature. It requests that \fBpcretest\fP
466 output a representation of the compiled code after compilation. Normally this
467 information contains length and offset values; however, if \fB/Z\fP is also
468 present, this data is replaced by spaces. This is a special feature for use in
469 the automatic test scripts; it ensures that the same output is generated for
470 different internal link sizes.
471 .P
472 The \fB/D\fP modifier is a PCRE debugging feature, and is equivalent to
473 \fB/BI\fP, that is, both the \fB/B\fP and the \fB/I\fP modifiers.
474 .P
475 The \fB/F\fP modifier causes \fBpcretest\fP to flip the byte order of the
476 2-byte and 4-byte fields in the compiled pattern. This facility is for testing
477 the feature in PCRE that allows it to execute patterns that were compiled on a
478 host with a different endianness. This feature is not available when the POSIX
479 interface to PCRE is being used, that is, when the \fB/P\fP pattern modifier is
480 specified. See also the section about saving and reloading compiled patterns
481 below.
482 .P
483 The \fB/I\fP modifier requests that \fBpcretest\fP output information about the
484 compiled pattern (whether it is anchored, has a fixed first character, and
485 so on). It does this by calling \fBpcre[16|32]_fullinfo()\fP after compiling a
486 pattern. If the pattern is studied, the results of that are also output.
487 .P
488 The \fB/K\fP modifier requests \fBpcretest\fP to show names from backtracking
489 control verbs that are returned from calls to \fBpcre[16|32]_exec()\fP. It causes
490 \fBpcretest\fP to create a \fBpcre[16|32]_extra\fP block if one has not already
491 been created by a call to \fBpcre[16|32]_study()\fP, and to set the
492 PCRE_EXTRA_MARK flag and the \fBmark\fP field within it, every time that
493 \fBpcre[16|32]_exec()\fP is called. If the variable that the \fBmark\fP field
494 points to is non-NULL for a match, non-match, or partial match, \fBpcretest\fP
495 prints the string to which it points. For a match, this is shown on a line by
496 itself, tagged with "MK:". For a non-match it is added to the message.
497 .P
498 The \fB/L\fP modifier must be followed directly by the name of a locale, for
499 example,
500 .sp
501 /pattern/Lfr_FR
502 .sp
503 For this reason, it must be the last modifier. The given locale is set,
504 \fBpcre[16|32]_maketables()\fP is called to build a set of character tables for
505 the locale, and this is then passed to \fBpcre[16|32]_compile()\fP when compiling
506 the regular expression. Without an \fB/L\fP (or \fB/T\fP) modifier, NULL is
507 passed as the tables pointer; that is, \fB/L\fP applies only to the expression
508 on which it appears.
509 .P
510 The \fB/M\fP modifier causes the size in bytes of the memory block used to hold
511 the compiled pattern to be output. This does not include the size of the
512 \fBpcre[16|32]\fP block; it is just the actual compiled data. If the pattern is
513 successfully studied with the PCRE_STUDY_JIT_COMPILE option, the size of the
514 JIT compiled code is also output.
515 .P
516 The \fB/S\fP modifier causes \fBpcre[16|32]_study()\fP to be called after the
517 expression has been compiled, and the results used when the expression is
518 matched. There are a number of qualifying characters that may follow \fB/S\fP.
519 They may appear in any order.
520 .P
521 If \fB/S\fP is followed by an exclamation mark, \fBpcre[16|32]_study()\fP is
522 called with the PCRE_STUDY_EXTRA_NEEDED option, causing it always to return a
523 \fBpcre_extra\fP block, even when studying discovers no useful information.
524 .P
525 If \fB/S\fP is followed by a second S character, it suppresses studying, even
526 if it was requested externally by the \fB-s\fP command line option. This makes
527 it possible to specify that certain patterns are always studied, and others are
528 never studied, independently of \fB-s\fP. This feature is used in the test
529 files in a few cases where the output is different when the pattern is studied.
530 .P
531 If the \fB/S\fP modifier is followed by a + character, the call to
532 \fBpcre[16|32]_study()\fP is made with all the JIT study options, requesting
533 just-in-time optimization support if it is available, for both normal and
534 partial matching. If you want to restrict the JIT compiling modes, you can
535 follow \fB/S+\fP with a digit in the range 1 to 7:
536 .sp
537 1 normal match only
538 2 soft partial match only
539 3 normal match and soft partial match
540 4 hard partial match only
541 6 soft and hard partial match
542 7 all three modes (default)
543 .sp
544 If \fB/S++\fP is used instead of \fB/S+\fP (with or without a following digit),
545 the text "(JIT)" is added to the first output line after a match or no match
546 when JIT-compiled code was actually used.
547 .P
548 Note that there is also an independent \fB/+\fP modifier; it must not be given
549 immediately after \fB/S\fP or \fB/S+\fP because this will be misinterpreted.
550 .P
551 If JIT studying is successful, the compiled JIT code will automatically be used
552 when \fBpcre[16|32]_exec()\fP is run, except when incompatible run-time options
553 are specified. For more details, see the
554 .\" HREF
555 \fBpcrejit\fP
556 .\"
557 documentation. See also the \fB\eJ\fP escape sequence below for a way of
558 setting the size of the JIT stack.
559 .P
560 Finally, if \fB/S\fP is followed by a minus character, JIT compilation is
561 suppressed, even if it was requested externally by the \fB-s\fP command line
562 option. This makes it possible to specify that JIT is never to be used for
563 certain patterns.
564 .P
565 The \fB/T\fP modifier must be followed by a single digit. It causes a specific
566 set of built-in character tables to be passed to \fBpcre[16|32]_compile()\fP. It
567 is used in the standard PCRE tests to check behaviour with different character
568 tables. The digit specifies the tables as follows:
569 .sp
570 0 the default ASCII tables, as distributed in
571 pcre_chartables.c.dist
572 1 a set of tables defining ISO 8859 characters
573 .sp
574 In table 1, some characters whose codes are greater than 128 are identified as
575 letters, digits, spaces, etc.
576 .
577 .
578 .SS "Using the POSIX wrapper API"
579 .rs
580 .sp
581 The \fB/P\fP modifier causes \fBpcretest\fP to call PCRE via the POSIX wrapper
582 API rather than its native API. This supports only the 8-bit library. When
583 \fB/P\fP is set, the following modifiers set options for the \fBregcomp()\fP
584 function:
585 .sp
586 /i REG_ICASE
587 /m REG_NEWLINE
588 /N REG_NOSUB
589 /s REG_DOTALL )
590 /U REG_UNGREEDY ) These options are not part of
591 /W REG_UCP ) the POSIX standard
592 /8 REG_UTF8 )
593 .sp
594 The \fB/+\fP modifier works as described above. All other modifiers are
595 ignored.
596 .
597 .
598 .SS "Locking out certain modifiers"
599 .rs
600 .sp
601 PCRE can be compiled with or without support for certain features such as
602 UTF-8/16/32 or Unicode properties. Accordingly, the standard tests are split up
603 into a number of different files that are selected for running depending on
604 which features are available. When updating the tests, it is all too easy to
605 put a new test into the wrong file by mistake; for example, to put a test that
606 requires UTF support into a file that is used when it is not available. To help
607 detect such mistakes as early as possible, there is a facility for locking out
608 specific modifiers. If an input line for \fBpcretest\fP starts with the string
609 "< forbid " the following sequence of characters is taken as a list of
610 forbidden modifiers. For example, in the test files that must not use UTF or
611 Unicode property support, this line appears:
612 .sp
613 < forbid 8W
614 .sp
615 This locks out the /8 and /W modifiers. An immediate error is given if they are
616 subsequently encountered. If the character string contains < but not >, all the
617 multi-character modifiers that begin with < are locked out. Otherwise, such
618 modifiers must be explicitly listed, for example:
619 .sp
620 < forbid <JS><cr>
621 .sp
622 There must be a single space between < and "forbid" for this feature to be
623 recognised. If there is not, the line is interpreted either as a request to
624 re-load a pre-compiled pattern (see "SAVING AND RELOADING COMPILED PATTERNS"
625 below) or, if there is a another < character, as a pattern that uses < as its
626 delimiter.
627 .
628 .
629 .SH "DATA LINES"
630 .rs
631 .sp
632 Before each data line is passed to \fBpcre[16|32]_exec()\fP, leading and trailing
633 white space is removed, and it is then scanned for \e escapes. Some of these
634 are pretty esoteric features, intended for checking out some of the more
635 complicated features of PCRE. If you are just testing "ordinary" regular
636 expressions, you probably don't need any of these. The following escapes are
637 recognized:
638 .sp
639 \ea alarm (BEL, \ex07)
640 \eb backspace (\ex08)
641 \ee escape (\ex27)
642 \ef form feed (\ex0c)
643 \en newline (\ex0a)
644 .\" JOIN
645 \eqdd set the PCRE_MATCH_LIMIT limit to dd
646 (any number of digits)
647 \er carriage return (\ex0d)
648 \et tab (\ex09)
649 \ev vertical tab (\ex0b)
650 \ennn octal character (up to 3 octal digits); always
651 a byte unless > 255 in UTF-8 or 16-bit or 32-bit mode
652 \eo{dd...} octal character (any number of octal digits}
653 \exhh hexadecimal byte (up to 2 hex digits)
654 \ex{hh...} hexadecimal character (any number of hex digits)
655 .\" JOIN
656 \eA pass the PCRE_ANCHORED option to \fBpcre[16|32]_exec()\fP
657 or \fBpcre[16|32]_dfa_exec()\fP
658 .\" JOIN
659 \eB pass the PCRE_NOTBOL option to \fBpcre[16|32]_exec()\fP
660 or \fBpcre[16|32]_dfa_exec()\fP
661 .\" JOIN
662 \eCdd call pcre[16|32]_copy_substring() for substring dd
663 after a successful match (number less than 32)
664 .\" JOIN
665 \eCname call pcre[16|32]_copy_named_substring() for substring
666 "name" after a successful match (name termin-
667 ated by next non alphanumeric character)
668 .\" JOIN
669 \eC+ show the current captured substrings at callout
670 time
671 \eC- do not supply a callout function
672 .\" JOIN
673 \eC!n return 1 instead of 0 when callout number n is
674 reached
675 .\" JOIN
676 \eC!n!m return 1 instead of 0 when callout number n is
677 reached for the nth time
678 .\" JOIN
679 \eC*n pass the number n (may be negative) as callout
680 data; this is used as the callout return value
681 \eD use the \fBpcre[16|32]_dfa_exec()\fP match function
682 \eF only shortest match for \fBpcre[16|32]_dfa_exec()\fP
683 .\" JOIN
684 \eGdd call pcre[16|32]_get_substring() for substring dd
685 after a successful match (number less than 32)
686 .\" JOIN
687 \eGname call pcre[16|32]_get_named_substring() for substring
688 "name" after a successful match (name termin-
689 ated by next non-alphanumeric character)
690 .\" JOIN
691 \eJdd set up a JIT stack of dd kilobytes maximum (any
692 number of digits)
693 .\" JOIN
694 \eL call pcre[16|32]_get_substringlist() after a
695 successful match
696 .\" JOIN
697 \eM discover the minimum MATCH_LIMIT and
698 MATCH_LIMIT_RECURSION settings
699 .\" JOIN
700 \eN pass the PCRE_NOTEMPTY option to \fBpcre[16|32]_exec()\fP
701 or \fBpcre[16|32]_dfa_exec()\fP; if used twice, pass the
702 PCRE_NOTEMPTY_ATSTART option
703 .\" JOIN
704 \eOdd set the size of the output vector passed to
705 \fBpcre[16|32]_exec()\fP to dd (any number of digits)
706 .\" JOIN
707 \eP pass the PCRE_PARTIAL_SOFT option to \fBpcre[16|32]_exec()\fP
708 or \fBpcre[16|32]_dfa_exec()\fP; if used twice, pass the
709 PCRE_PARTIAL_HARD option
710 .\" JOIN
711 \eQdd set the PCRE_MATCH_LIMIT_RECURSION limit to dd
712 (any number of digits)
713 \eR pass the PCRE_DFA_RESTART option to \fBpcre[16|32]_dfa_exec()\fP
714 \eS output details of memory get/free calls during matching
715 .\" JOIN
716 \eY pass the PCRE_NO_START_OPTIMIZE option to \fBpcre[16|32]_exec()\fP
717 or \fBpcre[16|32]_dfa_exec()\fP
718 .\" JOIN
719 \eZ pass the PCRE_NOTEOL option to \fBpcre[16|32]_exec()\fP
720 or \fBpcre[16|32]_dfa_exec()\fP
721 .\" JOIN
722 \e? pass the PCRE_NO_UTF[8|16|32]_CHECK option to
723 \fBpcre[16|32]_exec()\fP or \fBpcre[16|32]_dfa_exec()\fP
724 .\" JOIN
725 \e>dd start the match at offset dd (optional "-"; then
726 any number of digits); this sets the \fIstartoffset\fP
727 argument for \fBpcre[16|32]_exec()\fP or \fBpcre[16|32]_dfa_exec()\fP
728 .\" JOIN
729 \e<cr> pass the PCRE_NEWLINE_CR option to \fBpcre[16|32]_exec()\fP
730 or \fBpcre[16|32]_dfa_exec()\fP
731 .\" JOIN
732 \e<lf> pass the PCRE_NEWLINE_LF option to \fBpcre[16|32]_exec()\fP
733 or \fBpcre[16|32]_dfa_exec()\fP
734 .\" JOIN
735 \e<crlf> pass the PCRE_NEWLINE_CRLF option to \fBpcre[16|32]_exec()\fP
736 or \fBpcre[16|32]_dfa_exec()\fP
737 .\" JOIN
738 \e<anycrlf> pass the PCRE_NEWLINE_ANYCRLF option to \fBpcre[16|32]_exec()\fP
739 or \fBpcre[16|32]_dfa_exec()\fP
740 .\" JOIN
741 \e<any> pass the PCRE_NEWLINE_ANY option to \fBpcre[16|32]_exec()\fP
742 or \fBpcre[16|32]_dfa_exec()\fP
743 .sp
744 The use of \ex{hh...} is not dependent on the use of the \fB/8\fP modifier on
745 the pattern. It is recognized always. There may be any number of hexadecimal
746 digits inside the braces; invalid values provoke error messages.
747 .P
748 Note that \exhh specifies one byte rather than one character in UTF-8 mode;
749 this makes it possible to construct invalid UTF-8 sequences for testing
750 purposes. On the other hand, \ex{hh} is interpreted as a UTF-8 character in
751 UTF-8 mode, generating more than one byte if the value is greater than 127.
752 When testing the 8-bit library not in UTF-8 mode, \ex{hh} generates one byte
753 for values less than 256, and causes an error for greater values.
754 .P
755 In UTF-16 mode, all 4-digit \ex{hhhh} values are accepted. This makes it
756 possible to construct invalid UTF-16 sequences for testing purposes.
757 .P
758 In UTF-32 mode, all 4- to 8-digit \ex{...} values are accepted. This makes it
759 possible to construct invalid UTF-32 sequences for testing purposes.
760 .P
761 The escapes that specify line ending sequences are literal strings, exactly as
762 shown. No more than one newline setting should be present in any data line.
763 .P
764 A backslash followed by anything else just escapes the anything else. If
765 the very last character is a backslash, it is ignored. This gives a way of
766 passing an empty line as data, since a real empty line terminates the data
767 input.
768 .P
769 The \fB\eJ\fP escape provides a way of setting the maximum stack size that is
770 used by the just-in-time optimization code. It is ignored if JIT optimization
771 is not being used. Providing a stack that is larger than the default 32K is
772 necessary only for very complicated patterns.
773 .P
774 If \eM is present, \fBpcretest\fP calls \fBpcre[16|32]_exec()\fP several times,
775 with different values in the \fImatch_limit\fP and \fImatch_limit_recursion\fP
776 fields of the \fBpcre[16|32]_extra\fP data structure, until it finds the minimum
777 numbers for each parameter that allow \fBpcre[16|32]_exec()\fP to complete without
778 error. Because this is testing a specific feature of the normal interpretive
779 \fBpcre[16|32]_exec()\fP execution, the use of any JIT optimization that might
780 have been set up by the \fB/S+\fP qualifier of \fB-s+\fP option is disabled.
781 .P
782 The \fImatch_limit\fP number is a measure of the amount of backtracking
783 that takes place, and checking it out can be instructive. For most simple
784 matches, the number is quite small, but for patterns with very large numbers of
785 matching possibilities, it can become large very quickly with increasing length
786 of subject string. The \fImatch_limit_recursion\fP number is a measure of how
787 much stack (or, if PCRE is compiled with NO_RECURSE, how much heap) memory is
788 needed to complete the match attempt.
789 .P
790 When \eO is used, the value specified may be higher or lower than the size set
791 by the \fB-O\fP command line option (or defaulted to 45); \eO applies only to
792 the call of \fBpcre[16|32]_exec()\fP for the line in which it appears.
793 .P
794 If the \fB/P\fP modifier was present on the pattern, causing the POSIX wrapper
795 API to be used, the only option-setting sequences that have any effect are \eB,
796 \eN, and \eZ, causing REG_NOTBOL, REG_NOTEMPTY, and REG_NOTEOL, respectively,
797 to be passed to \fBregexec()\fP.
798 .
799 .
800 .SH "THE ALTERNATIVE MATCHING FUNCTION"
801 .rs
802 .sp
803 By default, \fBpcretest\fP uses the standard PCRE matching function,
804 \fBpcre[16|32]_exec()\fP to match each data line. PCRE also supports an
805 alternative matching function, \fBpcre[16|32]_dfa_test()\fP, which operates in a
806 different way, and has some restrictions. The differences between the two
807 functions are described in the
808 .\" HREF
809 \fBpcrematching\fP
810 .\"
811 documentation.
812 .P
813 If a data line contains the \eD escape sequence, or if the command line
814 contains the \fB-dfa\fP option, the alternative matching function is used.
815 This function finds all possible matches at a given point. If, however, the \eF
816 escape sequence is present in the data line, it stops after the first match is
817 found. This is always the shortest possible match.
818 .
819 .
820 .SH "DEFAULT OUTPUT FROM PCRETEST"
821 .rs
822 .sp
823 This section describes the output when the normal matching function,
824 \fBpcre[16|32]_exec()\fP, is being used.
825 .P
826 When a match succeeds, \fBpcretest\fP outputs the list of captured substrings
827 that \fBpcre[16|32]_exec()\fP returns, starting with number 0 for the string that
828 matched the whole pattern. Otherwise, it outputs "No match" when the return is
829 PCRE_ERROR_NOMATCH, and "Partial match:" followed by the partially matching
830 substring when \fBpcre[16|32]_exec()\fP returns PCRE_ERROR_PARTIAL. (Note that
831 this is the entire substring that was inspected during the partial match; it
832 may include characters before the actual match start if a lookbehind assertion,
833 \eK, \eb, or \eB was involved.) For any other return, \fBpcretest\fP outputs
834 the PCRE negative error number and a short descriptive phrase. If the error is
835 a failed UTF string check, the offset of the start of the failing character and
836 the reason code are also output, provided that the size of the output vector is
837 at least two. Here is an example of an interactive \fBpcretest\fP run.
838 .sp
839 $ pcretest
840 PCRE version 8.13 2011-04-30
841 .sp
842 re> /^abc(\ed+)/
843 data> abc123
844 0: abc123
845 1: 123
846 data> xyz
847 No match
848 .sp
849 Unset capturing substrings that are not followed by one that is set are not
850 returned by \fBpcre[16|32]_exec()\fP, and are not shown by \fBpcretest\fP. In the
851 following example, there are two capturing substrings, but when the first data
852 line is matched, the second, unset substring is not shown. An "internal" unset
853 substring is shown as "<unset>", as for the second data line.
854 .sp
855 re> /(a)|(b)/
856 data> a
857 0: a
858 1: a
859 data> b
860 0: b
861 1: <unset>
862 2: b
863 .sp
864 If the strings contain any non-printing characters, they are output as \exhh
865 escapes if the value is less than 256 and UTF mode is not set. Otherwise they
866 are output as \ex{hh...} escapes. See below for the definition of non-printing
867 characters. If the pattern has the \fB/+\fP modifier, the output for substring
868 0 is followed by the the rest of the subject string, identified by "0+" like
869 this:
870 .sp
871 re> /cat/+
872 data> cataract
873 0: cat
874 0+ aract
875 .sp
876 If the pattern has the \fB/g\fP or \fB/G\fP modifier, the results of successive
877 matching attempts are output in sequence, like this:
878 .sp
879 re> /\eBi(\ew\ew)/g
880 data> Mississippi
881 0: iss
882 1: ss
883 0: iss
884 1: ss
885 0: ipp
886 1: pp
887 .sp
888 "No match" is output only if the first match attempt fails. Here is an example
889 of a failure message (the offset 4 that is specified by \e>4 is past the end of
890 the subject string):
891 .sp
892 re> /xyz/
893 data> xyz\e>4
894 Error -24 (bad offset value)
895 .P
896 If any of the sequences \fB\eC\fP, \fB\eG\fP, or \fB\eL\fP are present in a
897 data line that is successfully matched, the substrings extracted by the
898 convenience functions are output with C, G, or L after the string number
899 instead of a colon. This is in addition to the normal full list. The string
900 length (that is, the return from the extraction function) is given in
901 parentheses after each string for \fB\eC\fP and \fB\eG\fP.
902 .P
903 Note that whereas patterns can be continued over several lines (a plain ">"
904 prompt is used for continuations), data lines may not. However newlines can be
905 included in data by means of the \en escape (or \er, \er\en, etc., depending on
906 the newline sequence setting).
907 .
908 .
909 .
910 .SH "OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION"
911 .rs
912 .sp
913 When the alternative matching function, \fBpcre[16|32]_dfa_exec()\fP, is used (by
914 means of the \eD escape sequence or the \fB-dfa\fP command line option), the
915 output consists of a list of all the matches that start at the first point in
916 the subject where there is at least one match. For example:
917 .sp
918 re> /(tang|tangerine|tan)/
919 data> yellow tangerine\eD
920 0: tangerine
921 1: tang
922 2: tan
923 .sp
924 (Using the normal matching function on this data finds only "tang".) The
925 longest matching string is always given first (and numbered zero). After a
926 PCRE_ERROR_PARTIAL return, the output is "Partial match:", followed by the
927 partially matching substring. (Note that this is the entire substring that was
928 inspected during the partial match; it may include characters before the actual
929 match start if a lookbehind assertion, \eK, \eb, or \eB was involved.)
930 .P
931 If \fB/g\fP is present on the pattern, the search for further matches resumes
932 at the end of the longest match. For example:
933 .sp
934 re> /(tang|tangerine|tan)/g
935 data> yellow tangerine and tangy sultana\eD
936 0: tangerine
937 1: tang
938 2: tan
939 0: tang
940 1: tan
941 0: tan
942 .sp
943 Since the matching function does not support substring capture, the escape
944 sequences that are concerned with captured substrings are not relevant.
945 .
946 .
947 .SH "RESTARTING AFTER A PARTIAL MATCH"
948 .rs
949 .sp
950 When the alternative matching function has given the PCRE_ERROR_PARTIAL return,
951 indicating that the subject partially matched the pattern, you can restart the
952 match with additional subject data by means of the \eR escape sequence. For
953 example:
954 .sp
955 re> /^\ed?\ed(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\ed\ed$/
956 data> 23ja\eP\eD
957 Partial match: 23ja
958 data> n05\eR\eD
959 0: n05
960 .sp
961 For further information about partial matching, see the
962 .\" HREF
963 \fBpcrepartial\fP
964 .\"
965 documentation.
966 .
967 .
968 .SH CALLOUTS
969 .rs
970 .sp
971 If the pattern contains any callout requests, \fBpcretest\fP's callout function
972 is called during matching. This works with both matching functions. By default,
973 the called function displays the callout number, the start and current
974 positions in the text at the callout time, and the next pattern item to be
975 tested. For example:
976 .sp
977 --->pqrabcdef
978 0 ^ ^ \ed
979 .sp
980 This output indicates that callout number 0 occurred for a match attempt
981 starting at the fourth character of the subject string, when the pointer was at
982 the seventh character of the data, and when the next pattern item was \ed. Just
983 one circumflex is output if the start and current positions are the same.
984 .P
985 Callouts numbered 255 are assumed to be automatic callouts, inserted as a
986 result of the \fB/C\fP pattern modifier. In this case, instead of showing the
987 callout number, the offset in the pattern, preceded by a plus, is output. For
988 example:
989 .sp
990 re> /\ed?[A-E]\e*/C
991 data> E*
992 --->E*
993 +0 ^ \ed?
994 +3 ^ [A-E]
995 +8 ^^ \e*
996 +10 ^ ^
997 0: E*
998 .sp
999 If a pattern contains (*MARK) items, an additional line is output whenever
1000 a change of latest mark is passed to the callout function. For example:
1001 .sp
1002 re> /a(*MARK:X)bc/C
1003 data> abc
1004 --->abc
1005 +0 ^ a
1006 +1 ^^ (*MARK:X)
1007 +10 ^^ b
1008 Latest Mark: X
1009 +11 ^ ^ c
1010 +12 ^ ^
1011 0: abc
1012 .sp
1013 The mark changes between matching "a" and "b", but stays the same for the rest
1014 of the match, so nothing more is output. If, as a result of backtracking, the
1015 mark reverts to being unset, the text "<unset>" is output.
1016 .P
1017 The callout function in \fBpcretest\fP returns zero (carry on matching) by
1018 default, but you can use a \eC item in a data line (as described above) to
1019 change this and other parameters of the callout.
1020 .P
1021 Inserting callouts can be helpful when using \fBpcretest\fP to check
1022 complicated regular expressions. For further information about callouts, see
1023 the
1024 .\" HREF
1025 \fBpcrecallout\fP
1026 .\"
1027 documentation.
1028 .
1029 .
1030 .
1031 .SH "NON-PRINTING CHARACTERS"
1032 .rs
1033 .sp
1034 When \fBpcretest\fP is outputting text in the compiled version of a pattern,
1035 bytes other than 32-126 are always treated as non-printing characters are are
1036 therefore shown as hex escapes.
1037 .P
1038 When \fBpcretest\fP is outputting text that is a matched part of a subject
1039 string, it behaves in the same way, unless a different locale has been set for
1040 the pattern (using the \fB/L\fP modifier). In this case, the \fBisprint()\fP
1041 function to distinguish printing and non-printing characters.
1042 .
1043 .
1044 .
1045 .SH "SAVING AND RELOADING COMPILED PATTERNS"
1046 .rs
1047 .sp
1048 The facilities described in this section are not available when the POSIX
1049 interface to PCRE is being used, that is, when the \fB/P\fP pattern modifier is
1050 specified.
1051 .P
1052 When the POSIX interface is not in use, you can cause \fBpcretest\fP to write a
1053 compiled pattern to a file, by following the modifiers with > and a file name.
1054 For example:
1055 .sp
1056 /pattern/im >/some/file
1057 .sp
1058 See the
1059 .\" HREF
1060 \fBpcreprecompile\fP
1061 .\"
1062 documentation for a discussion about saving and re-using compiled patterns.
1063 Note that if the pattern was successfully studied with JIT optimization, the
1064 JIT data cannot be saved.
1065 .P
1066 The data that is written is binary. The first eight bytes are the length of the
1067 compiled pattern data followed by the length of the optional study data, each
1068 written as four bytes in big-endian order (most significant byte first). If
1069 there is no study data (either the pattern was not studied, or studying did not
1070 return any data), the second length is zero. The lengths are followed by an
1071 exact copy of the compiled pattern. If there is additional study data, this
1072 (excluding any JIT data) follows immediately after the compiled pattern. After
1073 writing the file, \fBpcretest\fP expects to read a new pattern.
1074 .P
1075 A saved pattern can be reloaded into \fBpcretest\fP by specifying < and a file
1076 name instead of a pattern. There must be no space between < and the file name,
1077 which must not contain a < character, as otherwise \fBpcretest\fP will
1078 interpret the line as a pattern delimited by < characters. For example:
1079 .sp
1080 re> </some/file
1081 Compiled pattern loaded from /some/file
1082 No study data
1083 .sp
1084 If the pattern was previously studied with the JIT optimization, the JIT
1085 information cannot be saved and restored, and so is lost. When the pattern has
1086 been loaded, \fBpcretest\fP proceeds to read data lines in the usual way.
1087 .P
1088 You can copy a file written by \fBpcretest\fP to a different host and reload it
1089 there, even if the new host has opposite endianness to the one on which the
1090 pattern was compiled. For example, you can compile on an i86 machine and run on
1091 a SPARC machine. When a pattern is reloaded on a host with different
1092 endianness, the confirmation message is changed to:
1093 .sp
1094 Compiled pattern (byte-inverted) loaded from /some/file
1095 .sp
1096 The test suite contains some saved pre-compiled patterns with different
1097 endianness. These are reloaded using "<!" instead of just "<". This suppresses
1098 the "(byte-inverted)" text so that the output is the same on all hosts. It also
1099 forces debugging output once the pattern has been reloaded.
1100 .P
1101 File names for saving and reloading can be absolute or relative, but note that
1102 the shell facility of expanding a file name that starts with a tilde (~) is not
1103 available.
1104 .P
1105 The ability to save and reload files in \fBpcretest\fP is intended for testing
1106 and experimentation. It is not intended for production use because only a
1107 single pattern can be written to a file. Furthermore, there is no facility for
1108 supplying custom character tables for use with a reloaded pattern. If the
1109 original pattern was compiled with custom tables, an attempt to match a subject
1110 string using a reloaded pattern is likely to cause \fBpcretest\fP to crash.
1111 Finally, if you attempt to load a file that is not in the correct format, the
1112 result is undefined.
1113 .
1114 .
1115 .SH "SEE ALSO"
1116 .rs
1117 .sp
1118 \fBpcre\fP(3), \fBpcre16\fP(3), \fBpcre32\fP(3), \fBpcreapi\fP(3),
1119 \fBpcrecallout\fP(3),
1120 \fBpcrejit\fP, \fBpcrematching\fP(3), \fBpcrepartial\fP(d),
1121 \fBpcrepattern\fP(3), \fBpcreprecompile\fP(3).
1122 .
1123 .
1124 .SH AUTHOR
1125 .rs
1126 .sp
1127 .nf
1128 Philip Hazel
1129 University Computing Service
1130 Cambridge CB2 3QH, England.
1131 .fi
1132 .
1133 .
1134 .SH REVISION
1135 .rs
1136 .sp
1137 .nf
1138 Last updated: 12 November 2013
1139 Copyright (c) 1997-2013 University of Cambridge.
1140 .fi

Properties

Name Value
svn:eol-style native
svn:keywords "Author Date Id Revision Url"

  ViewVC Help
Powered by ViewVC 1.1.5