summaryrefslogtreecommitdiff
path: root/libs/regex/doc/html/boost_regex/format/perl_format.html
blob: c87ac993647f4567c3c0d7c2094bc630b2024670 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Perl Format String Syntax</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="../../index.html" title="Boost.Regex 5.0.0">
<link rel="up" href="../format.html" title="Search and Replace Format String Syntax">
<link rel="prev" href="sed_format.html" title="Sed Format String Syntax">
<link rel="next" href="boost_format_syntax.html" title="Boost-Extended Format String Syntax">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="sed_format.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../format.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost_format_syntax.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_regex.format.perl_format"></a><a class="link" href="perl_format.html" title="Perl Format String Syntax">Perl Format String Syntax</a>
</h3></div></div></div>
<p>
        Perl-style format strings treat all characters as literals except '$' and
        '\' which start placeholder and escape sequences respectively.
      </p>
<p>
        Placeholder sequences specify that some part of what matched the regular
        expression should be sent to output as follows:
      </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                <p>
                  Placeholder
                </p>
              </th>
<th>
                <p>
                  Meaning
                </p>
              </th>
</tr></thead>
<tbody>
<tr>
<td>
                <p>
                  $&amp;
                </p>
              </td>
<td>
                <p>
                  Outputs what matched the whole expression.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  $MATCH
                </p>
              </td>
<td>
                <p>
                  As $&amp;
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  ${^MATCH}
                </p>
              </td>
<td>
                <p>
                  As $&amp;
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  $`
                </p>
              </td>
<td>
                <p>
                  Outputs the text between the end of the last match found (or the
                  start of the text if no previous match was found), and the start
                  of the current match.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  $PREMATCH
                </p>
              </td>
<td>
                <p>
                  As $`
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  ${^PREMATCH}
                </p>
              </td>
<td>
                <p>
                  As $`
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  $'
                </p>
              </td>
<td>
                <p>
                  Outputs all the text following the end of the current match.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  $POSTMATCH
                </p>
              </td>
<td>
                <p>
                  As $'
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  ${^POSTMATCH}
                </p>
              </td>
<td>
                <p>
                  As $'
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  $+
                </p>
              </td>
<td>
                <p>
                  Outputs what matched the last marked sub-expression in the regular
                  expression.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  $LAST_PAREN_MATCH
                </p>
              </td>
<td>
                <p>
                  As $+
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  $LAST_SUBMATCH_RESULT
                </p>
              </td>
<td>
                <p>
                  Outputs what matched the last sub-expression to be actually matched.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  $^N
                </p>
              </td>
<td>
                <p>
                  As $LAST_SUBMATCH_RESULT
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  $$
                </p>
              </td>
<td>
                <p>
                  Outputs a literal '$'
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  $n
                </p>
              </td>
<td>
                <p>
                  Outputs what matched the n'th sub-expression.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  ${n}
                </p>
              </td>
<td>
                <p>
                  Outputs what matched the n'th sub-expression.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  $+{NAME}
                </p>
              </td>
<td>
                <p>
                  Outputs whatever matched the sub-expression named "NAME".
                </p>
              </td>
</tr>
</tbody>
</table></div>
<p>
        Any $-placeholder sequence not listed above, results in '$' being treated
        as a literal.
      </p>
<p>
        An escape character followed by any character x, outputs that character unless
        x is one of the escape sequences shown below.
      </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                <p>
                  Escape
                </p>
              </th>
<th>
                <p>
                  Meaning
                </p>
              </th>
</tr></thead>
<tbody>
<tr>
<td>
                <p>
                  \a
                </p>
              </td>
<td>
                <p>
                  Outputs the bell character: '\a'.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  \e
                </p>
              </td>
<td>
                <p>
                  Outputs the ANSI escape character (code point 27).
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  \f
                </p>
              </td>
<td>
                <p>
                  Outputs a form feed character: '\f'
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  \n
                </p>
              </td>
<td>
                <p>
                  Outputs a newline character: '\n'.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  \r
                </p>
              </td>
<td>
                <p>
                  Outputs a carriage return character: '\r'.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  \t
                </p>
              </td>
<td>
                <p>
                  Outputs a tab character: '\t'.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  \v
                </p>
              </td>
<td>
                <p>
                  Outputs a vertical tab character: '\v'.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  \xDD
                </p>
              </td>
<td>
                <p>
                  Outputs the character whose hexadecimal code point is 0xDD
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  \x{DDDD}
                </p>
              </td>
<td>
                <p>
                  Outputs the character whose hexadecimal code point is 0xDDDDD
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  \cX
                </p>
              </td>
<td>
                <p>
                  Outputs the ANSI escape sequence "escape-X".
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  \D
                </p>
              </td>
<td>
                <p>
                  If D is a decimal digit in the range 1-9, then outputs the text
                  that matched sub-expression D.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  \l
                </p>
              </td>
<td>
                <p>
                  Causes the next character to be outputted, to be output in lower
                  case.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  \u
                </p>
              </td>
<td>
                <p>
                  Causes the next character to be outputted, to be output in upper
                  case.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  \L
                </p>
              </td>
<td>
                <p>
                  Causes all subsequent characters to be output in lower case, until
                  a \E is found.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  \U
                </p>
              </td>
<td>
                <p>
                  Causes all subsequent characters to be output in upper case, until
                  a \E is found.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  \E
                </p>
              </td>
<td>
                <p>
                  Terminates a \L or \U sequence.
                </p>
              </td>
</tr>
</tbody>
</table></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 1998-2013 John Maddock<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="sed_format.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../format.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost_format_syntax.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>