/[pcre]/code/tags/pcre-6.4/doc/html/pcretest.html
ViewVC logotype

Contents of /code/tags/pcre-6.4/doc/html/pcretest.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 86 - (show annotations) (download) (as text)
Sat Feb 24 21:41:15 2007 UTC (7 years, 1 month ago) by nigel
File MIME type: text/html
File size: 24503 byte(s)
Tag code/trunk as code/tags/pcre-6.4.

1 <html>
2 <head>
3 <title>pcretest specification</title>
4 </head>
5 <body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
6 <h1>pcretest man page</h1>
7 <p>
8 Return to the <a href="index.html">PCRE index page</a>.
9 </p>
10 <p>
11 This page is part of the PCRE HTML documentation. It was generated automatically
12 from the original man page. If there is any nonsense in it, please consult the
13 man page, in case the conversion went wrong.
14 <br>
15 <ul>
16 <li><a name="TOC1" href="#SEC1">SYNOPSIS</a>
17 <li><a name="TOC2" href="#SEC2">OPTIONS</a>
18 <li><a name="TOC3" href="#SEC3">DESCRIPTION</a>
19 <li><a name="TOC4" href="#SEC4">PATTERN MODIFIERS</a>
20 <li><a name="TOC5" href="#SEC5">DATA LINES</a>
21 <li><a name="TOC6" href="#SEC6">THE ALTERNATIVE MATCHING FUNCTION</a>
22 <li><a name="TOC7" href="#SEC7">DEFAULT OUTPUT FROM PCRETEST</a>
23 <li><a name="TOC8" href="#SEC8">OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION</a>
24 <li><a name="TOC9" href="#SEC9">RESTARTING AFTER A PARTIAL MATCH</a>
25 <li><a name="TOC10" href="#SEC10">CALLOUTS</a>
26 <li><a name="TOC11" href="#SEC11">SAVING AND RELOADING COMPILED PATTERNS</a>
27 <li><a name="TOC12" href="#SEC12">AUTHOR</a>
28 </ul>
29 <br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br>
30 <P>
31 <b>pcretest [-C] [-d] [-dfa] [-i] [-m] [-o osize] [-p] [-t] [source]</b>
32 <b>[destination]</b>
33 </P>
34 <P>
35 <b>pcretest</b> was written as a test program for the PCRE regular expression
36 library itself, but it can also be used for experimenting with regular
37 expressions. This document describes the features of the test program; for
38 details of the regular expressions themselves, see the
39 <a href="pcrepattern.html"><b>pcrepattern</b></a>
40 documentation. For details of the PCRE library function calls and their
41 options, see the
42 <a href="pcreapi.html"><b>pcreapi</b></a>
43 documentation.
44 </P>
45 <br><a name="SEC2" href="#TOC1">OPTIONS</a><br>
46 <P>
47 <b>-C</b>
48 Output the version number of the PCRE library, and all available information
49 about the optional features that are included, and then exit.
50 </P>
51 <P>
52 <b>-d</b>
53 Behave as if each regex has the <b>/D</b> (debug) modifier; the internal
54 form is output after compilation.
55 </P>
56 <P>
57 <b>-dfa</b>
58 Behave as if each data line contains the \D escape sequence; this causes the
59 alternative matching function, <b>pcre_dfa_exec()</b>, to be used instead of the
60 standard <b>pcre_exec()</b> function (more detail is given below).
61 </P>
62 <P>
63 <b>-i</b>
64 Behave as if each regex has the <b>/I</b> modifier; information about the
65 compiled pattern is given after compilation.
66 </P>
67 <P>
68 <b>-m</b>
69 Output the size of each compiled pattern after it has been compiled. This is
70 equivalent to adding <b>/M</b> to each regular expression. For compatibility
71 with earlier versions of pcretest, <b>-s</b> is a synonym for <b>-m</b>.
72 </P>
73 <P>
74 <b>-o</b> <i>osize</i>
75 Set the number of elements in the output vector that is used when calling
76 <b>pcre_exec()</b> to be <i>osize</i>. The default value is 45, which is enough
77 for 14 capturing subexpressions. The vector size can be changed for individual
78 matching calls by including \O in the data line (see below).
79 </P>
80 <P>
81 <b>-p</b>
82 Behave as if each regex has the <b>/P</b> modifier; the POSIX wrapper API is
83 used to call PCRE. None of the other options has any effect when <b>-p</b> is
84 set.
85 </P>
86 <P>
87 <b>-t</b>
88 Run each compile, study, and match many times with a timer, and output
89 resulting time per compile or match (in milliseconds). Do not set <b>-m</b> with
90 <b>-t</b>, because you will then get the size output a zillion times, and the
91 timing will be distorted.
92 </P>
93 <br><a name="SEC3" href="#TOC1">DESCRIPTION</a><br>
94 <P>
95 If <b>pcretest</b> is given two filename arguments, it reads from the first and
96 writes to the second. If it is given only one filename argument, it reads from
97 that file and writes to stdout. Otherwise, it reads from stdin and writes to
98 stdout, and prompts for each line of input, using "re&#62;" to prompt for regular
99 expressions, and "data&#62;" to prompt for data lines.
100 </P>
101 <P>
102 The program handles any number of sets of input on a single input file. Each
103 set starts with a regular expression, and continues with any number of data
104 lines to be matched against the pattern.
105 </P>
106 <P>
107 Each data line is matched separately and independently. If you want to do
108 multiple-line matches, you have to use the \n escape sequence in a single line
109 of input to encode the newline characters. The maximum length of data line is
110 30,000 characters.
111 </P>
112 <P>
113 An empty line signals the end of the data lines, at which point a new regular
114 expression is read. The regular expressions are given enclosed in any
115 non-alphanumeric delimiters other than backslash, for example
116 <pre>
117 /(a|bc)x+yz/
118 </pre>
119 White space before the initial delimiter is ignored. A regular expression may
120 be continued over several input lines, in which case the newline characters are
121 included within it. It is possible to include the delimiter within the pattern
122 by escaping it, for example
123 <pre>
124 /abc\/def/
125 </pre>
126 If you do so, the escape and the delimiter form part of the pattern, but since
127 delimiters are always non-alphanumeric, this does not affect its interpretation.
128 If the terminating delimiter is immediately followed by a backslash, for
129 example,
130 <pre>
131 /abc/\
132 </pre>
133 then a backslash is added to the end of the pattern. This is done to provide a
134 way of testing the error condition that arises if a pattern finishes with a
135 backslash, because
136 <pre>
137 /abc\/
138 </pre>
139 is interpreted as the first line of a pattern that starts with "abc/", causing
140 pcretest to read the next line as a continuation of the regular expression.
141 </P>
142 <br><a name="SEC4" href="#TOC1">PATTERN MODIFIERS</a><br>
143 <P>
144 A pattern may be followed by any number of modifiers, which are mostly single
145 characters. Following Perl usage, these are referred to below as, for example,
146 "the <b>/i</b> modifier", even though the delimiter of the pattern need not
147 always be a slash, and no slash is used when writing modifiers. Whitespace may
148 appear between the final pattern delimiter and the first modifier, and between
149 the modifiers themselves.
150 </P>
151 <P>
152 The <b>/i</b>, <b>/m</b>, <b>/s</b>, and <b>/x</b> modifiers set the PCRE_CASELESS,
153 PCRE_MULTILINE, PCRE_DOTALL, or PCRE_EXTENDED options, respectively, when
154 <b>pcre_compile()</b> is called. These four modifier letters have the same
155 effect as they do in Perl. For example:
156 <pre>
157 /caseless/i
158 </pre>
159 The following table shows additional modifiers for setting PCRE options that do
160 not correspond to anything in Perl:
161 <pre>
162 <b>/A</b> PCRE_ANCHORED
163 <b>/C</b> PCRE_AUTO_CALLOUT
164 <b>/E</b> PCRE_DOLLAR_ENDONLY
165 <b>/f</b> PCRE_FIRSTLINE
166 <b>/N</b> PCRE_NO_AUTO_CAPTURE
167 <b>/U</b> PCRE_UNGREEDY
168 <b>/X</b> PCRE_EXTRA
169 </pre>
170 Searching for all possible matches within each subject string can be requested
171 by the <b>/g</b> or <b>/G</b> modifier. After finding a match, PCRE is called
172 again to search the remainder of the subject string. The difference between
173 <b>/g</b> and <b>/G</b> is that the former uses the <i>startoffset</i> argument to
174 <b>pcre_exec()</b> to start searching at a new point within the entire string
175 (which is in effect what Perl does), whereas the latter passes over a shortened
176 substring. This makes a difference to the matching process if the pattern
177 begins with a lookbehind assertion (including \b or \B).
178 </P>
179 <P>
180 If any call to <b>pcre_exec()</b> in a <b>/g</b> or <b>/G</b> sequence matches an
181 empty string, the next call is done with the PCRE_NOTEMPTY and PCRE_ANCHORED
182 flags set in order to search for another, non-empty, match at the same point.
183 If this second match fails, the start offset is advanced by one, and the normal
184 match is retried. This imitates the way Perl handles such cases when using the
185 <b>/g</b> modifier or the <b>split()</b> function.
186 </P>
187 <P>
188 There are yet more modifiers for controlling the way <b>pcretest</b>
189 operates.
190 </P>
191 <P>
192 The <b>/+</b> modifier requests that as well as outputting the substring that
193 matched the entire pattern, pcretest should in addition output the remainder of
194 the subject string. This is useful for tests where the subject contains
195 multiple copies of the same substring.
196 </P>
197 <P>
198 The <b>/L</b> modifier must be followed directly by the name of a locale, for
199 example,
200 <pre>
201 /pattern/Lfr_FR
202 </pre>
203 For this reason, it must be the last modifier. The given locale is set,
204 <b>pcre_maketables()</b> is called to build a set of character tables for the
205 locale, and this is then passed to <b>pcre_compile()</b> when compiling the
206 regular expression. Without an <b>/L</b> modifier, NULL is passed as the tables
207 pointer; that is, <b>/L</b> applies only to the expression on which it appears.
208 </P>
209 <P>
210 The <b>/I</b> modifier requests that <b>pcretest</b> output information about the
211 compiled pattern (whether it is anchored, has a fixed first character, and
212 so on). It does this by calling <b>pcre_fullinfo()</b> after compiling a
213 pattern. If the pattern is studied, the results of that are also output.
214 </P>
215 <P>
216 The <b>/D</b> modifier is a PCRE debugging feature, which also assumes <b>/I</b>.
217 It causes the internal form of compiled regular expressions to be output after
218 compilation. If the pattern was studied, the information returned is also
219 output.
220 </P>
221 <P>
222 The <b>/F</b> modifier causes <b>pcretest</b> to flip the byte order of the
223 fields in the compiled pattern that contain 2-byte and 4-byte numbers. This
224 facility is for testing the feature in PCRE that allows it to execute patterns
225 that were compiled on a host with a different endianness. This feature is not
226 available when the POSIX interface to PCRE is being used, that is, when the
227 <b>/P</b> pattern modifier is specified. See also the section about saving and
228 reloading compiled patterns below.
229 </P>
230 <P>
231 The <b>/S</b> modifier causes <b>pcre_study()</b> to be called after the
232 expression has been compiled, and the results used when the expression is
233 matched.
234 </P>
235 <P>
236 The <b>/M</b> modifier causes the size of memory block used to hold the compiled
237 pattern to be output.
238 </P>
239 <P>
240 The <b>/P</b> modifier causes <b>pcretest</b> to call PCRE via the POSIX wrapper
241 API rather than its native API. When this is done, all other modifiers except
242 <b>/i</b>, <b>/m</b>, and <b>/+</b> are ignored. REG_ICASE is set if <b>/i</b> is
243 present, and REG_NEWLINE is set if <b>/m</b> is present. The wrapper functions
244 force PCRE_DOLLAR_ENDONLY always, and PCRE_DOTALL unless REG_NEWLINE is set.
245 </P>
246 <P>
247 The <b>/8</b> modifier causes <b>pcretest</b> to call PCRE with the PCRE_UTF8
248 option set. This turns on support for UTF-8 character handling in PCRE,
249 provided that it was compiled with this support enabled. This modifier also
250 causes any non-printing characters in output strings to be printed using the
251 \x{hh...} notation if they are valid UTF-8 sequences.
252 </P>
253 <P>
254 If the <b>/?</b> modifier is used with <b>/8</b>, it causes <b>pcretest</b> to
255 call <b>pcre_compile()</b> with the PCRE_NO_UTF8_CHECK option, to suppress the
256 checking of the string for UTF-8 validity.
257 </P>
258 <br><a name="SEC5" href="#TOC1">DATA LINES</a><br>
259 <P>
260 Before each data line is passed to <b>pcre_exec()</b>, leading and trailing
261 whitespace is removed, and it is then scanned for \ escapes. Some of these are
262 pretty esoteric features, intended for checking out some of the more
263 complicated features of PCRE. If you are just testing "ordinary" regular
264 expressions, you probably don't need any of these. The following escapes are
265 recognized:
266 <pre>
267 \a alarm (= BEL)
268 \b backspace
269 \e escape
270 \f formfeed
271 \n newline
272 \r carriage return
273 \t tab
274 \v vertical tab
275 \nnn octal character (up to 3 octal digits)
276 \xhh hexadecimal character (up to 2 hex digits)
277 \x{hh...} hexadecimal character, any number of digits in UTF-8 mode
278 \A pass the PCRE_ANCHORED option to <b>pcre_exec()</b>
279 \B pass the PCRE_NOTBOL option to <b>pcre_exec()</b>
280 \Cdd call pcre_copy_substring() for substring dd after a successful match (number less than 32)
281 \Cname call pcre_copy_named_substring() for substring "name" after a successful match (name termin-
282 ated by next non alphanumeric character)
283 \C+ show the current captured substrings at callout time
284 \C- do not supply a callout function
285 \C!n return 1 instead of 0 when callout number n is reached
286 \C!n!m return 1 instead of 0 when callout number n is reached for the nth time
287 \C*n pass the number n (may be negative) as callout data; this is used as the callout return value
288 \D use the <b>pcre_dfa_exec()</b> match function
289 \F only shortest match for <b>pcre_dfa_exec()</b>
290 \Gdd call pcre_get_substring() for substring dd after a successful match (number less than 32)
291 \Gname call pcre_get_named_substring() for substring "name" after a successful match (name termin-
292 ated by next non-alphanumeric character)
293 \L call pcre_get_substringlist() after a successful match
294 \M discover the minimum MATCH_LIMIT setting
295 \N pass the PCRE_NOTEMPTY option to <b>pcre_exec()</b>
296 \Odd set the size of the output vector passed to <b>pcre_exec()</b> to dd (any number of digits)
297 \P pass the PCRE_PARTIAL option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
298 \R pass the PCRE_DFA_RESTART option to <b>pcre_dfa_exec()</b>
299 \S output details of memory get/free calls during matching
300 \Z pass the PCRE_NOTEOL option to <b>pcre_exec()</b>
301 \? pass the PCRE_NO_UTF8_CHECK option to <b>pcre_exec()</b>
302 \&#62;dd start the match at offset dd (any number of digits);
303 this sets the <i>startoffset</i> argument for <b>pcre_exec()</b>
304 </pre>
305 A backslash followed by anything else just escapes the anything else. If the
306 very last character is a backslash, it is ignored. This gives a way of passing
307 an empty line as data, since a real empty line terminates the data input.
308 </P>
309 <P>
310 If \M is present, <b>pcretest</b> calls <b>pcre_exec()</b> several times, with
311 different values in the <i>match_limit</i> field of the <b>pcre_extra</b> data
312 structure, until it finds the minimum number that is needed for
313 <b>pcre_exec()</b> to complete. This number is a measure of the amount of
314 recursion and backtracking that takes place, and checking it out can be
315 instructive. For most simple matches, the number is quite small, but for
316 patterns with very large numbers of matching possibilities, it can become large
317 very quickly with increasing length of subject string.
318 </P>
319 <P>
320 When \O is used, the value specified may be higher or lower than the size set
321 by the <b>-O</b> command line option (or defaulted to 45); \O applies only to
322 the call of <b>pcre_exec()</b> for the line in which it appears.
323 </P>
324 <P>
325 If the <b>/P</b> modifier was present on the pattern, causing the POSIX wrapper
326 API to be used, only \B and \Z have any effect, causing REG_NOTBOL and
327 REG_NOTEOL to be passed to <b>regexec()</b> respectively.
328 </P>
329 <P>
330 The use of \x{hh...} to represent UTF-8 characters is not dependent on the use
331 of the <b>/8</b> modifier on the pattern. It is recognized always. There may be
332 any number of hexadecimal digits inside the braces. The result is from one to
333 six bytes, encoded according to the UTF-8 rules.
334 </P>
335 <br><a name="SEC6" href="#TOC1">THE ALTERNATIVE MATCHING FUNCTION</a><br>
336 <P>
337 By default, <b>pcretest</b> uses the standard PCRE matching function,
338 <b>pcre_exec()</b> to match each data line. From release 6.0, PCRE supports an
339 alternative matching function, <b>pcre_dfa_test()</b>, which operates in a
340 different way, and has some restrictions. The differences between the two
341 functions are described in the
342 <a href="pcrematching.html"><b>pcrematching</b></a>
343 documentation.
344 </P>
345 <P>
346 If a data line contains the \D escape sequence, or if the command line
347 contains the <b>-dfa</b> option, the alternative matching function is called.
348 This function finds all possible matches at a given point. If, however, the \F
349 escape sequence is present in the data line, it stops after the first match is
350 found. This is always the shortest possible match.
351 </P>
352 <br><a name="SEC7" href="#TOC1">DEFAULT OUTPUT FROM PCRETEST</a><br>
353 <P>
354 This section describes the output when the normal matching function,
355 <b>pcre_exec()</b>, is being used.
356 </P>
357 <P>
358 When a match succeeds, pcretest outputs the list of captured substrings that
359 <b>pcre_exec()</b> returns, starting with number 0 for the string that matched
360 the whole pattern. Otherwise, it outputs "No match" or "Partial match"
361 when <b>pcre_exec()</b> returns PCRE_ERROR_NOMATCH or PCRE_ERROR_PARTIAL,
362 respectively, and otherwise the PCRE negative error number. Here is an example
363 of an interactive <b>pcretest</b> run.
364 <pre>
365 $ pcretest
366 PCRE version 5.00 07-Sep-2004
367
368 re&#62; /^abc(\d+)/
369 data&#62; abc123
370 0: abc123
371 1: 123
372 data&#62; xyz
373 No match
374 </pre>
375 If the strings contain any non-printing characters, they are output as \0x
376 escapes, or as \x{...} escapes if the <b>/8</b> modifier was present on the
377 pattern. If the pattern has the <b>/+</b> modifier, the output for substring 0
378 is followed by the the rest of the subject string, identified by "0+" like
379 this:
380 <pre>
381 re&#62; /cat/+
382 data&#62; cataract
383 0: cat
384 0+ aract
385 </pre>
386 If the pattern has the <b>/g</b> or <b>/G</b> modifier, the results of successive
387 matching attempts are output in sequence, like this:
388 <pre>
389 re&#62; /\Bi(\w\w)/g
390 data&#62; Mississippi
391 0: iss
392 1: ss
393 0: iss
394 1: ss
395 0: ipp
396 1: pp
397 </pre>
398 "No match" is output only if the first match attempt fails.
399 </P>
400 <P>
401 If any of the sequences <b>\C</b>, <b>\G</b>, or <b>\L</b> are present in a
402 data line that is successfully matched, the substrings extracted by the
403 convenience functions are output with C, G, or L after the string number
404 instead of a colon. This is in addition to the normal full list. The string
405 length (that is, the return from the extraction function) is given in
406 parentheses after each string for <b>\C</b> and <b>\G</b>.
407 </P>
408 <P>
409 Note that while patterns can be continued over several lines (a plain "&#62;"
410 prompt is used for continuations), data lines may not. However newlines can be
411 included in data by means of the \n escape.
412 </P>
413 <br><a name="SEC8" href="#TOC1">OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION</a><br>
414 <P>
415 When the alternative matching function, <b>pcre_dfa_exec()</b>, is used (by
416 means of the \D escape sequence or the <b>-dfa</b> command line option), the
417 output consists of a list of all the matches that start at the first point in
418 the subject where there is at least one match. For example:
419 <pre>
420 re&#62; /(tang|tangerine|tan)/
421 data&#62; yellow tangerine\D
422 0: tangerine
423 1: tang
424 2: tan
425 </pre>
426 (Using the normal matching function on this data finds only "tang".) The
427 longest matching string is always given first (and numbered zero).
428 </P>
429 <P>
430 If \fB/g\P is present on the pattern, the search for further matches resumes
431 at the end of the longest match. For example:
432 <pre>
433 re&#62; /(tang|tangerine|tan)/g
434 data&#62; yellow tangerine and tangy sultana\D
435 0: tangerine
436 1: tang
437 2: tan
438 0: tang
439 1: tan
440 0: tan
441 </pre>
442 Since the matching function does not support substring capture, the escape
443 sequences that are concerned with captured substrings are not relevant.
444 </P>
445 <br><a name="SEC9" href="#TOC1">RESTARTING AFTER A PARTIAL MATCH</a><br>
446 <P>
447 When the alternative matching function has given the PCRE_ERROR_PARTIAL return,
448 indicating that the subject partially matched the pattern, you can restart the
449 match with additional subject data by means of the \R escape sequence. For
450 example:
451 <pre>
452 re&#62; /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
453 data&#62; 23ja\P\D
454 Partial match: 23ja
455 data&#62; n05\R\D
456 0: n05
457 </pre>
458 For further information about partial matching, see the
459 <a href="pcrepartial.html"><b>pcrepartial</b></a>
460 documentation.
461 </P>
462 <br><a name="SEC10" href="#TOC1">CALLOUTS</a><br>
463 <P>
464 If the pattern contains any callout requests, <b>pcretest</b>'s callout function
465 is called during matching. This works with both matching functions. By default,
466 the called function displays the callout number, the start and current
467 positions in the text at the callout time, and the next pattern item to be
468 tested. For example, the output
469 <pre>
470 ---&#62;pqrabcdef
471 0 ^ ^ \d
472 </pre>
473 indicates that callout number 0 occurred for a match attempt starting at the
474 fourth character of the subject string, when the pointer was at the seventh
475 character of the data, and when the next pattern item was \d. Just one
476 circumflex is output if the start and current positions are the same.
477 </P>
478 <P>
479 Callouts numbered 255 are assumed to be automatic callouts, inserted as a
480 result of the <b>/C</b> pattern modifier. In this case, instead of showing the
481 callout number, the offset in the pattern, preceded by a plus, is output. For
482 example:
483 <pre>
484 re&#62; /\d?[A-E]\*/C
485 data&#62; E*
486 ---&#62;E*
487 +0 ^ \d?
488 +3 ^ [A-E]
489 +8 ^^ \*
490 +10 ^ ^
491 0: E*
492 </pre>
493 The callout function in <b>pcretest</b> returns zero (carry on matching) by
494 default, but you can use a \C item in a data line (as described above) to
495 change this.
496 </P>
497 <P>
498 Inserting callouts can be helpful when using <b>pcretest</b> to check
499 complicated regular expressions. For further information about callouts, see
500 the
501 <a href="pcrecallout.html"><b>pcrecallout</b></a>
502 documentation.
503 </P>
504 <br><a name="SEC11" href="#TOC1">SAVING AND RELOADING COMPILED PATTERNS</a><br>
505 <P>
506 The facilities described in this section are not available when the POSIX
507 inteface to PCRE is being used, that is, when the <b>/P</b> pattern modifier is
508 specified.
509 </P>
510 <P>
511 When the POSIX interface is not in use, you can cause <b>pcretest</b> to write a
512 compiled pattern to a file, by following the modifiers with &#62; and a file name.
513 For example:
514 <pre>
515 /pattern/im &#62;/some/file
516 </pre>
517 See the
518 <a href="pcreprecompile.html"><b>pcreprecompile</b></a>
519 documentation for a discussion about saving and re-using compiled patterns.
520 </P>
521 <P>
522 The data that is written is binary. The first eight bytes are the length of the
523 compiled pattern data followed by the length of the optional study data, each
524 written as four bytes in big-endian order (most significant byte first). If
525 there is no study data (either the pattern was not studied, or studying did not
526 return any data), the second length is zero. The lengths are followed by an
527 exact copy of the compiled pattern. If there is additional study data, this
528 follows immediately after the compiled pattern. After writing the file,
529 <b>pcretest</b> expects to read a new pattern.
530 </P>
531 <P>
532 A saved pattern can be reloaded into <b>pcretest</b> by specifing &#60; and a file
533 name instead of a pattern. The name of the file must not contain a &#60; character,
534 as otherwise <b>pcretest</b> will interpret the line as a pattern delimited by &#60;
535 characters.
536 For example:
537 <pre>
538 re&#62; &#60;/some/file
539 Compiled regex loaded from /some/file
540 No study data
541 </pre>
542 When the pattern has been loaded, <b>pcretest</b> proceeds to read data lines in
543 the usual way.
544 </P>
545 <P>
546 You can copy a file written by <b>pcretest</b> to a different host and reload it
547 there, even if the new host has opposite endianness to the one on which the
548 pattern was compiled. For example, you can compile on an i86 machine and run on
549 a SPARC machine.
550 </P>
551 <P>
552 File names for saving and reloading can be absolute or relative, but note that
553 the shell facility of expanding a file name that starts with a tilde (~) is not
554 available.
555 </P>
556 <P>
557 The ability to save and reload files in <b>pcretest</b> is intended for testing
558 and experimentation. It is not intended for production use because only a
559 single pattern can be written to a file. Furthermore, there is no facility for
560 supplying custom character tables for use with a reloaded pattern. If the
561 original pattern was compiled with custom tables, an attempt to match a subject
562 string using a reloaded pattern is likely to cause <b>pcretest</b> to crash.
563 Finally, if you attempt to load a file that is not in the correct format, the
564 result is undefined.
565 </P>
566 <br><a name="SEC12" href="#TOC1">AUTHOR</a><br>
567 <P>
568 Philip Hazel
569 <br>
570 University Computing Service,
571 <br>
572 Cambridge CB2 3QG, England.
573 </P>
574 <P>
575 Last updated: 28 February 2005
576 <br>
577 Copyright &copy; 1997-2005 University of Cambridge.
578 <p>
579 Return to the <a href="index.html">PCRE index page</a>.
580 </p>

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12