| 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%" |
|---|
| 14 | border="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 |
|---|
| 38 | match_results::format instead. Existing code will continue to |
|---|
| 39 | compile, the following documentation is taken from the previous |
|---|
| 40 | version of boost.regex and will not be further updated:</p> |
|---|
| 41 | |
|---|
| 42 | <h3>Algorithm regex_format</h3> |
|---|
| 43 | |
|---|
| 44 | <pre> |
|---|
| 45 | #include <<a href="../../../boost/regex.hpp">boost/regex.hpp</a>> |
|---|
| 46 | </pre> |
|---|
| 47 | |
|---|
| 48 | <p>The algorithm regex_format takes the results of a match and |
|---|
| 49 | creates a new string based upon a <a href="format_syntax.html"> |
|---|
| 50 | format string</a>, regex_format can be used for search and replace |
|---|
| 51 | operations:</p> |
|---|
| 52 | |
|---|
| 53 | <pre> |
|---|
| 54 | <b>template</b> <<b>class</b> OutputIterator, <b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT> |
|---|
| 55 | OutputIterator regex_format(OutputIterator out, |
|---|
| 56 | <b>const</b> match_results<iterator, Allocator>& m, |
|---|
| 57 | <b>const</b> charT* fmt, |
|---|
| 58 | match_flag_type flags = 0); |
|---|
| 59 | <b>template</b> <<b>class</b> OutputIterator, <b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT> |
|---|
| 60 | OutputIterator regex_format(OutputIterator out, |
|---|
| 61 | <b>const</b> match_results<iterator, Allocator>& m, |
|---|
| 62 | <b>const</b> std::basic_string<charT>& fmt, |
|---|
| 63 | match_flag_type flags = 0); |
|---|
| 64 | </pre> |
|---|
| 65 | |
|---|
| 66 | <p>The library also defines the following convenience variation of |
|---|
| 67 | regex_format, which returns the result directly as a string, rather |
|---|
| 68 | than outputting to an iterator [note - this version may not be |
|---|
| 69 | available, or may be available in a more limited form, depending |
|---|
| 70 | upon your compilers capabilities]:</p> |
|---|
| 71 | |
|---|
| 72 | <pre> |
|---|
| 73 | <b>template</b> <<b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT> |
|---|
| 74 | std::basic_string<charT> regex_format |
|---|
| 75 | (<b>const</b> match_results<iterator, Allocator>& m, |
|---|
| 76 | <b>const</b> charT* fmt, |
|---|
| 77 | match_flag_type flags = 0); |
|---|
| 78 | |
|---|
| 79 | <b>template</b> <<b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT> |
|---|
| 80 | std::basic_string<charT> regex_format |
|---|
| 81 | (<b>const</b> match_results<iterator, Allocator>& m, |
|---|
| 82 | <b>const</b> std::basic_string<charT>& fmt, |
|---|
| 83 | match_flag_type flags = 0); |
|---|
| 84 | </pre> |
|---|
| 85 | |
|---|
| 86 | <p>Parameters to the main version of the function are passed as |
|---|
| 87 | follows:</p> |
|---|
| 88 | |
|---|
| 89 | <p></p> |
|---|
| 90 | |
|---|
| 91 | <table id="Table2" cellspacing="0" cellpadding="7" width="100%" |
|---|
| 92 | border="0"> |
|---|
| 93 | <tr> |
|---|
| 94 | <td valign="top" width="9%"> </td> |
|---|
| 95 | <td valign="top" width="39%">OutputIterator out</td> |
|---|
| 96 | <td valign="top" width="44%">An output iterator type, the output |
|---|
| 97 | string is sent to this iterator. Typically this would be a |
|---|
| 98 | std::ostream_iterator.</td> |
|---|
| 99 | <td valign="top" width="9%"> </td> |
|---|
| 100 | </tr> |
|---|
| 101 | |
|---|
| 102 | <tr> |
|---|
| 103 | <td valign="top" width="9%"> </td> |
|---|
| 104 | <td valign="top" width="39%"><b>const</b> |
|---|
| 105 | match_results<iterator, Allocator>& m</td> |
|---|
| 106 | <td valign="top" width="44%">An instance of match_results<> |
|---|
| 107 | obtained from one of the matching algorithms above, and denoting |
|---|
| 108 | what matched.</td> |
|---|
| 109 | <td valign="top" width="9%"> </td> |
|---|
| 110 | </tr> |
|---|
| 111 | |
|---|
| 112 | <tr> |
|---|
| 113 | <td valign="top" width="9%"> </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 |
|---|
| 116 | the match is transformed into the new string.</td> |
|---|
| 117 | <td valign="top" width="9%"> </td> |
|---|
| 118 | </tr> |
|---|
| 119 | |
|---|
| 120 | <tr> |
|---|
| 121 | <td valign="top" width="9%"> </td> |
|---|
| 122 | <td valign="top" width="39%"><b>unsigned</b> flags</td> |
|---|
| 123 | <td valign="top" width="44%">Optional flags which describe how the |
|---|
| 124 | format string is to be interpreted.</td> |
|---|
| 125 | <td valign="top" width="9%"> </td> |
|---|
| 126 | </tr> |
|---|
| 127 | </table> |
|---|
| 128 | |
|---|
| 129 | <br> |
|---|
| 130 | <br> |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | <p><a name="format_flags"></a>Format flags are defined as |
|---|
| 134 | follows:</p> |
|---|
| 135 | |
|---|
| 136 | <p></p> |
|---|
| 137 | |
|---|
| 138 | <table id="Table3" cellspacing="0" cellpadding="7" width="100%" |
|---|
| 139 | border="0"> |
|---|
| 140 | <tr> |
|---|
| 141 | <td valign="top" width="9%"> </td> |
|---|
| 142 | <td valign="top" width="39%">format_all</td> |
|---|
| 143 | <td valign="top" width="43%">Enables all syntax options (perl-like |
|---|
| 144 | plus extentions).</td> |
|---|
| 145 | <td valign="top" width="9%"> </td> |
|---|
| 146 | </tr> |
|---|
| 147 | |
|---|
| 148 | <tr> |
|---|
| 149 | <td valign="top" width="9%"> </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%"> </td> |
|---|
| 153 | </tr> |
|---|
| 154 | |
|---|
| 155 | <tr> |
|---|
| 156 | <td valign="top" width="9%"> </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%"> </td> |
|---|
| 160 | </tr> |
|---|
| 161 | |
|---|
| 162 | <tr> |
|---|
| 163 | <td valign="top" width="9%"> </td> |
|---|
| 164 | <td valign="top" width="39%">format_no_copy</td> |
|---|
| 165 | <td valign="top" width="43%">Disables copying of unmatched sections |
|---|
| 166 | to the output string during <a href="regex_merge.html"> |
|---|
| 167 | regex_merge</a> operations.</td> |
|---|
| 168 | <td valign="top" width="9%"> </td> |
|---|
| 169 | </tr> |
|---|
| 170 | |
|---|
| 171 | <tr> |
|---|
| 172 | <td> </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> </td> |
|---|
| 177 | </tr> |
|---|
| 178 | </table> |
|---|
| 179 | |
|---|
| 180 | <br> |
|---|
| 181 | <br> |
|---|
| 182 | |
|---|
| 183 | |
|---|
| 184 | <p>The format string syntax (and available options) is described |
|---|
| 185 | more 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 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 | |
|---|