Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/regex/doc/regex_format.html @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 6.7 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<meta name="generator" content="HTML Tidy, see www.w3.org">
5<title>Boost.Regex: Algorithm regex_format (deprecated)</title>
6<meta http-equiv="Content-Type" content=
7"text/html; charset=iso-8859-1">
8<link rel="stylesheet" type="text/css" href="../../../boost.css">
9</head>
10<body>
11<p></p>
12
13<table id="Table1" cellspacing="1" cellpadding="1" width="100%"
14border="0">
15<tr>
16<td valign="top" width="300">
17<h3><a href="../../../index.htm"><img height="86" width="277" alt=
18"C++ Boost" src="../../../boost.png" border="0"></a></h3>
19</td>
20<td width="353">
21<h1 align="center">Boost.Regex</h1>
22
23<h2 align="center">Algorithm regex_format (deprecated)</h2>
24</td>
25<td width="50">
26<h3><a href="index.html"><img height="45" width="43" alt=
27"Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
28</td>
29</tr>
30</table>
31
32<br>
33<br>
34 
35
36<hr>
37<p>The algorithm regex_format is deprecated; new code should use
38match_results::format instead.&nbsp; Existing code will continue to
39compile, the following documentation is taken from the previous
40version of boost.regex and will not be further updated:</p>
41
42<h3>Algorithm regex_format</h3>
43
44<pre>
45#include &lt;<a href="../../../boost/regex.hpp">boost/regex.hpp</a>&gt;
46</pre>
47
48<p>The algorithm regex_format takes the results of a match and
49creates a new string based upon a <a href="format_syntax.html">
50format string</a>, regex_format can be used for search and replace
51operations:</p>
52
53<pre>
54<b>template</b> &lt;<b>class</b> OutputIterator, <b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT&gt;
55OutputIterator regex_format(OutputIterator out,
56                            <b>const</b> match_results&lt;iterator, Allocator&gt;&amp; m,
57                            <b>const</b> charT* fmt,
58                            match_flag_type flags = 0);
59<b>template</b> &lt;<b>class</b> OutputIterator, <b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT&gt;
60OutputIterator regex_format(OutputIterator out,
61                            <b>const</b> match_results&lt;iterator, Allocator&gt;&amp; m,
62                            <b>const</b> std::basic_string&lt;charT&gt;&amp; fmt,
63                            match_flag_type flags = 0);
64</pre>
65
66<p>The library also defines the following convenience variation of
67regex_format, which returns the result directly as a string, rather
68than outputting to an iterator [note - this version may not be
69available, or may be available in a more limited form, depending
70upon your compilers capabilities]:</p>
71
72<pre>
73<b>template</b> &lt;<b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT&gt;
74std::basic_string&lt;charT&gt; regex_format
75                                 (<b>const</b> match_results&lt;iterator, Allocator&gt;&amp; m,
76                                  <b>const</b> charT* fmt,
77                                  match_flag_type flags = 0);
78
79<b>template</b> &lt;<b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT&gt;
80std::basic_string&lt;charT&gt; regex_format
81                                 (<b>const</b> match_results&lt;iterator, Allocator&gt;&amp; m,
82                                  <b>const</b> std::basic_string&lt;charT&gt;&amp; fmt,
83                                  match_flag_type flags = 0);
84</pre>
85
86<p>Parameters to the main version of the function are passed as
87follows:</p>
88
89<p></p>
90
91<table id="Table2" cellspacing="0" cellpadding="7" width="100%"
92border="0">
93<tr>
94<td valign="top" width="9%">&nbsp;</td>
95<td valign="top" width="39%">OutputIterator out</td>
96<td valign="top" width="44%">An output iterator type, the output
97string is sent to this iterator. Typically this would be a
98std::ostream_iterator.</td>
99<td valign="top" width="9%">&nbsp;</td>
100</tr>
101
102<tr>
103<td valign="top" width="9%">&nbsp;</td>
104<td valign="top" width="39%"><b>const</b>
105match_results&lt;iterator, Allocator&gt;&amp; m</td>
106<td valign="top" width="44%">An instance of match_results&lt;&gt;
107obtained from one of the matching algorithms above, and denoting
108what matched.</td>
109<td valign="top" width="9%">&nbsp;</td>
110</tr>
111
112<tr>
113<td valign="top" width="9%">&nbsp;</td>
114<td valign="top" width="39%"><b>const</b> charT* fmt</td>
115<td valign="top" width="44%">A format string that determines how
116the match is transformed into the new string.</td>
117<td valign="top" width="9%">&nbsp;</td>
118</tr>
119
120<tr>
121<td valign="top" width="9%">&nbsp;</td>
122<td valign="top" width="39%"><b>unsigned</b> flags</td>
123<td valign="top" width="44%">Optional flags which describe how the
124format string is to be interpreted.</td>
125<td valign="top" width="9%">&nbsp;</td>
126</tr>
127</table>
128
129<br>
130<br>
131 
132
133<p><a name="format_flags"></a>Format flags are defined as
134follows:</p>
135
136<p></p>
137
138<table id="Table3" cellspacing="0" cellpadding="7" width="100%"
139border="0">
140<tr>
141<td valign="top" width="9%">&nbsp;</td>
142<td valign="top" width="39%">format_all</td>
143<td valign="top" width="43%">Enables all syntax options (perl-like
144plus extentions).</td>
145<td valign="top" width="9%">&nbsp;</td>
146</tr>
147
148<tr>
149<td valign="top" width="9%">&nbsp;</td>
150<td valign="top" width="39%">format_sed</td>
151<td valign="top" width="43%">Allows only a sed-like syntax.</td>
152<td valign="top" width="9%">&nbsp;</td>
153</tr>
154
155<tr>
156<td valign="top" width="9%">&nbsp;</td>
157<td valign="top" width="39%">format_perl</td>
158<td valign="top" width="43%">Allows only a perl-like syntax.</td>
159<td valign="top" width="9%">&nbsp;</td>
160</tr>
161
162<tr>
163<td valign="top" width="9%">&nbsp;</td>
164<td valign="top" width="39%">format_no_copy</td>
165<td valign="top" width="43%">Disables copying of unmatched sections
166to the output string during <a href="regex_merge.html">
167regex_merge</a> operations.</td>
168<td valign="top" width="9%">&nbsp;</td>
169</tr>
170
171<tr>
172<td>&nbsp;</td>
173<td>format_first_only</td>
174<td>When this flag is set only the first occurance will be replaced
175(applies to regex_merge only).</td>
176<td>&nbsp;</td>
177</tr>
178</table>
179
180<br>
181<br>
182 
183
184<p>The format string syntax (and available options) is described
185more fully under <a href="format_syntax.html">format strings</a>
186.</p>
187
188<p></p>
189
190<hr>
191      <p>Revised
192         <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan --> 
193         24 Oct 2003
194         <!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
195      <p><i>© Copyright John Maddock&nbsp;1998-
196            <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 
197            2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
198      <P><I>Use, modification and distribution are subject to the Boost Software License,
199            Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
200            or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
201</body>
202</html>
203
204
Note: See TracBrowser for help on using the repository browser.