• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Unicode Aware Regex Iterators</title>
5<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../../../index.html" title="Boost.Regex 5.1.4">
8<link rel="up" href="../icu.html" title="Working With Unicode and ICU String Types">
9<link rel="prev" href="unicode_algo.html" title="Unicode Regular Expression Algorithms">
10<link rel="next" href="../mfc_strings.html" title="Using Boost Regex With MFC Strings">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="unicode_algo.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../icu.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="../mfc_strings.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h5 class="title">
27<a name="boost_regex.ref.non_std_strings.icu.unicode_iter"></a><a class="link" href="unicode_iter.html" title="Unicode Aware Regex Iterators">Unicode
28          Aware Regex Iterators</a>
29</h5></div></div></div>
30<h5>
31<a name="boost_regex.ref.non_std_strings.icu.unicode_iter.h0"></a>
32            <span class="phrase"><a name="boost_regex.ref.non_std_strings.icu.unicode_iter.u32regex_iterator"></a></span><a class="link" href="unicode_iter.html#boost_regex.ref.non_std_strings.icu.unicode_iter.u32regex_iterator">u32regex_iterator</a>
33          </h5>
34<p>
35            Type <code class="computeroutput"><span class="identifier">u32regex_iterator</span></code>
36            is in all respects the same as <a class="link" href="../../regex_iterator.html" title="regex_iterator"><code class="computeroutput"><span class="identifier">regex_iterator</span></code></a> except that since
37            the regular expression type is always <code class="computeroutput"><span class="identifier">u32regex</span></code>
38            it only takes one template parameter (the iterator type). It also calls
39            <code class="computeroutput"><span class="identifier">u32regex_search</span></code> internally,
40            allowing it to interface correctly with UTF-8, UTF-16, and UTF-32 data:
41          </p>
42<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">BidirectionalIterator</span><span class="special">&gt;</span>
43<span class="keyword">class</span> <span class="identifier">u32regex_iterator</span>
44<span class="special">{</span>
45   <span class="comment">// for members see regex_iterator</span>
46<span class="special">};</span>
47
48<span class="keyword">typedef</span> <span class="identifier">u32regex_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*&gt;</span>     <span class="identifier">utf8regex_iterator</span><span class="special">;</span>
49<span class="keyword">typedef</span> <span class="identifier">u32regex_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">UChar</span><span class="special">*&gt;</span>    <span class="identifier">utf16regex_iterator</span><span class="special">;</span>
50<span class="keyword">typedef</span> <span class="identifier">u32regex_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">UChar32</span><span class="special">*&gt;</span>  <span class="identifier">utf32regex_iterator</span><span class="special">;</span>
51</pre>
52<p>
53            In order to simplify the construction of a <code class="computeroutput"><span class="identifier">u32regex_iterator</span></code>
54            from a string, there are a series of non-member helper functions called
55            make_u32regex_iterator:
56          </p>
57<pre class="programlisting"><span class="identifier">u32regex_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*&gt;</span>
58   <span class="identifier">make_u32regex_iterator</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">s</span><span class="special">,</span>
59                          <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
60                          <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
61
62<span class="identifier">u32regex_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*&gt;</span>
63   <span class="identifier">make_u32regex_iterator</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*</span> <span class="identifier">s</span><span class="special">,</span>
64                          <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
65                          <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
66
67<span class="identifier">u32regex_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">UChar</span><span class="special">*&gt;</span>
68   <span class="identifier">make_u32regex_iterator</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">UChar</span><span class="special">*</span> <span class="identifier">s</span><span class="special">,</span>
69                          <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
70                          <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
71
72<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">charT</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Traits</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Alloc</span><span class="special">&gt;</span>
73<span class="identifier">u32regex_iterator</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_string</span><span class="special">&lt;</span><span class="identifier">charT</span><span class="special">,</span> <span class="identifier">Traits</span><span class="special">,</span> <span class="identifier">Alloc</span><span class="special">&gt;::</span><span class="identifier">const_iterator</span><span class="special">&gt;</span>
74   <span class="identifier">make_u32regex_iterator</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_string</span><span class="special">&lt;</span><span class="identifier">charT</span><span class="special">,</span> <span class="identifier">Traits</span><span class="special">,</span> <span class="identifier">Alloc</span><span class="special">&gt;&amp;</span> <span class="identifier">s</span><span class="special">,</span>
75                          <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
76                          <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
77
78<span class="identifier">u32regex_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">UChar</span><span class="special">*&gt;</span>
79   <span class="identifier">make_u32regex_iterator</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">UnicodeString</span><span class="special">&amp;</span> <span class="identifier">s</span><span class="special">,</span>
80                          <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
81                          <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
82</pre>
83<p>
84            Each of these overloads returns an iterator that enumerates all occurrences
85            of expression <span class="emphasis"><em>e</em></span>, in text <span class="emphasis"><em>s</em></span>,
86            using match_flags <span class="emphasis"><em>m</em></span>.
87          </p>
88<p>
89            Example: search for international currency symbols, along with their
90            associated numeric value:
91          </p>
92<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">enumerate_currencies</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;</span> <span class="identifier">text</span><span class="special">)</span>
93<span class="special">{</span>
94   <span class="comment">// enumerate and print all the currency symbols, along</span>
95   <span class="comment">// with any associated numeric values:</span>
96   <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">re</span> <span class="special">=</span>
97      <span class="string">"([[:Sc:]][[:Cf:][:Cc:][:Z*:]]*)?"</span>
98      <span class="string">"([[:Nd:]]+(?:[[:Po:]][[:Nd:]]+)?)?"</span>
99      <span class="string">"(?(1)"</span>
100         <span class="string">"|(?(2)"</span>
101            <span class="string">"[[:Cf:][:Cc:][:Z*:]]*"</span>
102         <span class="string">")"</span>
103         <span class="string">"[[:Sc:]]"</span>
104      <span class="string">")"</span><span class="special">;</span>
105   <span class="identifier">boost</span><span class="special">::</span><span class="identifier">u32regex</span> <span class="identifier">r</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">make_u32regex</span><span class="special">(</span><span class="identifier">re</span><span class="special">);</span>
106   <span class="identifier">boost</span><span class="special">::</span><span class="identifier">u32regex_iterator</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">::</span><span class="identifier">const_iterator</span><span class="special">&gt;</span>
107         <span class="identifier">i</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">make_u32regex_iterator</span><span class="special">(</span><span class="identifier">text</span><span class="special">,</span> <span class="identifier">r</span><span class="special">)),</span> <span class="identifier">j</span><span class="special">;</span>
108   <span class="keyword">while</span><span class="special">(</span><span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">j</span><span class="special">)</span>
109   <span class="special">{</span>
110      <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">(*</span><span class="identifier">i</span><span class="special">)[</span><span class="number">0</span><span class="special">]</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
111      <span class="special">++</span><span class="identifier">i</span><span class="special">;</span>
112   <span class="special">}</span>
113<span class="special">}</span>
114</pre>
115<p>
116            Calling
117          </p>
118<pre class="programlisting">enumerate_currencies(" $100.23 or £198.12 ");</pre>
119<p>
120            Yields the output:
121          </p>
122<pre class="programlisting">$100.23
123£198.12
124</pre>
125<p>
126            Provided of course that the input is encoded as UTF-8.
127          </p>
128<h5>
129<a name="boost_regex.ref.non_std_strings.icu.unicode_iter.h1"></a>
130            <span class="phrase"><a name="boost_regex.ref.non_std_strings.icu.unicode_iter.u32regex_token_iterator"></a></span><a class="link" href="unicode_iter.html#boost_regex.ref.non_std_strings.icu.unicode_iter.u32regex_token_iterator">u32regex_token_iterator</a>
131          </h5>
132<p>
133            Type <code class="computeroutput"><span class="identifier">u32regex_token_iterator</span></code>
134            is in all respects the same as <a class="link" href="../../regex_token_iterator.html" title="regex_token_iterator"><code class="computeroutput"><span class="identifier">regex_token_iterator</span></code></a> except
135            that since the regular expression type is always <code class="computeroutput"><span class="identifier">u32regex</span></code>
136            it only takes one template parameter (the iterator type). It also calls
137            <code class="computeroutput"><span class="identifier">u32regex_search</span></code> internally,
138            allowing it to interface correctly with UTF-8, UTF-16, and UTF-32 data:
139          </p>
140<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">BidirectionalIterator</span><span class="special">&gt;</span>
141<span class="keyword">class</span> <span class="identifier">u32regex_token_iterator</span>
142<span class="special">{</span>
143   <span class="comment">// for members see regex_token_iterator</span>
144<span class="special">};</span>
145
146<span class="keyword">typedef</span> <span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*&gt;</span>     <span class="identifier">utf8regex_token_iterator</span><span class="special">;</span>
147<span class="keyword">typedef</span> <span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">UChar</span><span class="special">*&gt;</span>    <span class="identifier">utf16regex_token_iterator</span><span class="special">;</span>
148<span class="keyword">typedef</span> <span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">UChar32</span><span class="special">*&gt;</span>  <span class="identifier">utf32regex_token_iterator</span><span class="special">;</span>
149</pre>
150<p>
151            In order to simplify the construction of a <code class="computeroutput"><span class="identifier">u32regex_token_iterator</span></code>
152            from a string, there are a series of non-member helper functions called
153            <code class="computeroutput"><span class="identifier">make_u32regex_token_iterator</span></code>:
154          </p>
155<pre class="programlisting"><span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*&gt;</span>
156   <span class="identifier">make_u32regex_token_iterator</span><span class="special">(</span>
157         <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">s</span><span class="special">,</span>
158         <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
159         <span class="keyword">int</span> <span class="identifier">sub</span><span class="special">,</span>
160         <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
161
162<span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*&gt;</span>
163   <span class="identifier">make_u32regex_token_iterator</span><span class="special">(</span>
164         <span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*</span> <span class="identifier">s</span><span class="special">,</span>
165         <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
166         <span class="keyword">int</span> <span class="identifier">sub</span><span class="special">,</span>
167         <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
168
169<span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">UChar</span><span class="special">*&gt;</span>
170   <span class="identifier">make_u32regex_token_iterator</span><span class="special">(</span>
171         <span class="keyword">const</span> <span class="identifier">UChar</span><span class="special">*</span> <span class="identifier">s</span><span class="special">,</span>
172         <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
173         <span class="keyword">int</span> <span class="identifier">sub</span><span class="special">,</span>
174         <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
175
176<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">charT</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Traits</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Alloc</span><span class="special">&gt;</span>
177<span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_string</span><span class="special">&lt;</span><span class="identifier">charT</span><span class="special">,</span> <span class="identifier">Traits</span><span class="special">,</span> <span class="identifier">Alloc</span><span class="special">&gt;::</span><span class="identifier">const_iterator</span><span class="special">&gt;</span>
178   <span class="identifier">make_u32regex_token_iterator</span><span class="special">(</span>
179         <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_string</span><span class="special">&lt;</span><span class="identifier">charT</span><span class="special">,</span> <span class="identifier">Traits</span><span class="special">,</span> <span class="identifier">Alloc</span><span class="special">&gt;&amp;</span> <span class="identifier">s</span><span class="special">,</span>
180         <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
181         <span class="keyword">int</span> <span class="identifier">sub</span><span class="special">,</span>
182         <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
183
184<span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">UChar</span><span class="special">*&gt;</span>
185   <span class="identifier">make_u32regex_token_iterator</span><span class="special">(</span>
186         <span class="keyword">const</span> <span class="identifier">UnicodeString</span><span class="special">&amp;</span> <span class="identifier">s</span><span class="special">,</span>
187         <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
188         <span class="keyword">int</span> <span class="identifier">sub</span><span class="special">,</span>
189         <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
190</pre>
191<p>
192            Each of these overloads returns an iterator that enumerates all occurrences
193            of marked sub-expression sub in regular expression <span class="emphasis"><em>e</em></span>,
194            found in text <span class="emphasis"><em>s</em></span>, using match_flags <span class="emphasis"><em>m</em></span>.
195          </p>
196<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">&gt;</span>
197<span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*&gt;</span>
198   <span class="identifier">make_u32regex_token_iterator</span><span class="special">(</span>
199         <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">p</span><span class="special">,</span>
200         <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
201         <span class="keyword">const</span> <span class="keyword">int</span> <span class="special">(&amp;</span><span class="identifier">submatch</span><span class="special">)[</span><span class="identifier">N</span><span class="special">],</span>
202         <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
203
204<span class="keyword">template</span> <span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">&gt;</span>
205<span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*&gt;</span>
206   <span class="identifier">make_u32regex_token_iterator</span><span class="special">(</span>
207         <span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*</span> <span class="identifier">p</span><span class="special">,</span>
208         <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
209         <span class="keyword">const</span> <span class="keyword">int</span> <span class="special">(&amp;</span><span class="identifier">submatch</span><span class="special">)[</span><span class="identifier">N</span><span class="special">],</span>
210         <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
211
212<span class="keyword">template</span> <span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">&gt;</span>
213<span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">UChar</span><span class="special">*&gt;</span>
214   <span class="identifier">make_u32regex_token_iterator</span><span class="special">(</span>
215         <span class="keyword">const</span> <span class="identifier">UChar</span><span class="special">*</span> <span class="identifier">p</span><span class="special">,</span>
216         <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
217         <span class="keyword">const</span> <span class="keyword">int</span> <span class="special">(&amp;</span><span class="identifier">submatch</span><span class="special">)[</span><span class="identifier">N</span><span class="special">],</span>
218         <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
219
220<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">charT</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Traits</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Alloc</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">&gt;</span>
221<span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_string</span><span class="special">&lt;</span><span class="identifier">charT</span><span class="special">,</span> <span class="identifier">Traits</span><span class="special">,</span> <span class="identifier">Alloc</span><span class="special">&gt;::</span><span class="identifier">const_iterator</span><span class="special">&gt;</span>
222   <span class="identifier">make_u32regex_token_iterator</span><span class="special">(</span>
223         <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_string</span><span class="special">&lt;</span><span class="identifier">charT</span><span class="special">,</span> <span class="identifier">Traits</span><span class="special">,</span> <span class="identifier">Alloc</span><span class="special">&gt;&amp;</span> <span class="identifier">p</span><span class="special">,</span>
224         <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
225         <span class="keyword">const</span> <span class="keyword">int</span> <span class="special">(&amp;</span><span class="identifier">submatch</span><span class="special">)[</span><span class="identifier">N</span><span class="special">],</span>
226         <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
227
228<span class="keyword">template</span> <span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">&gt;</span>
229<span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">UChar</span><span class="special">*&gt;</span>
230   <span class="identifier">make_u32regex_token_iterator</span><span class="special">(</span>
231         <span class="keyword">const</span> <span class="identifier">UnicodeString</span><span class="special">&amp;</span> <span class="identifier">s</span><span class="special">,</span>
232         <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
233         <span class="keyword">const</span> <span class="keyword">int</span> <span class="special">(&amp;</span><span class="identifier">submatch</span><span class="special">)[</span><span class="identifier">N</span><span class="special">],</span>
234         <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
235</pre>
236<p>
237            Each of these overloads returns an iterator that enumerates one sub-expression
238            for each submatch in regular expression <span class="emphasis"><em>e</em></span>, found
239            in text <span class="emphasis"><em>s</em></span>, using match_flags <span class="emphasis"><em>m</em></span>.
240          </p>
241<pre class="programlisting"><span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*&gt;</span>
242   <span class="identifier">make_u32regex_token_iterator</span><span class="special">(</span>
243         <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">p</span><span class="special">,</span>
244         <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
245         <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;&amp;</span> <span class="identifier">submatch</span><span class="special">,</span>
246         <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
247
248<span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*&gt;</span>
249   <span class="identifier">make_u32regex_token_iterator</span><span class="special">(</span>
250         <span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*</span> <span class="identifier">p</span><span class="special">,</span>
251         <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
252         <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;&amp;</span> <span class="identifier">submatch</span><span class="special">,</span>
253         <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
254
255<span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">UChar</span><span class="special">*&gt;</span>
256   <span class="identifier">make_u32regex_token_iterator</span><span class="special">(</span>
257         <span class="keyword">const</span> <span class="identifier">UChar</span><span class="special">*</span> <span class="identifier">p</span><span class="special">,</span>
258         <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
259         <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;&amp;</span> <span class="identifier">submatch</span><span class="special">,</span>
260         <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
261
262<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">charT</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Traits</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Alloc</span><span class="special">&gt;</span>
263<span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_string</span><span class="special">&lt;</span><span class="identifier">charT</span><span class="special">,</span> <span class="identifier">Traits</span><span class="special">,</span> <span class="identifier">Alloc</span><span class="special">&gt;::</span><span class="identifier">const_iterator</span><span class="special">&gt;</span>
264   <span class="identifier">make_u32regex_token_iterator</span><span class="special">(</span>
265         <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_string</span><span class="special">&lt;</span><span class="identifier">charT</span><span class="special">,</span> <span class="identifier">Traits</span><span class="special">,</span> <span class="identifier">Alloc</span><span class="special">&gt;&amp;</span> <span class="identifier">p</span><span class="special">,</span>
266         <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
267         <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;&amp;</span> <span class="identifier">submatch</span><span class="special">,</span>
268         <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
269
270<span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">UChar</span><span class="special">*&gt;</span>
271   <span class="identifier">make_u32regex_token_iterator</span><span class="special">(</span>
272         <span class="keyword">const</span> <span class="identifier">UnicodeString</span><span class="special">&amp;</span> <span class="identifier">s</span><span class="special">,</span>
273         <span class="keyword">const</span> <span class="identifier">u32regex</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">,</span>
274         <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;&amp;</span> <span class="identifier">submatch</span><span class="special">,</span>
275         <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">m</span> <span class="special">=</span> <span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
276</pre>
277<p>
278            Each of these overloads returns an iterator that enumerates one sub-expression
279            for each submatch in regular expression <span class="emphasis"><em>e</em></span>, found
280            in text <span class="emphasis"><em>s</em></span>, using match_flags <span class="emphasis"><em>m</em></span>.
281          </p>
282<p>
283            Example: search for international currency symbols, along with their
284            associated numeric value:
285          </p>
286<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">enumerate_currencies2</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;</span> <span class="identifier">text</span><span class="special">)</span>
287<span class="special">{</span>
288   <span class="comment">// enumerate and print all the currency symbols, along</span>
289   <span class="comment">// with any associated numeric values:</span>
290   <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">re</span> <span class="special">=</span>
291      <span class="string">"([[:Sc:]][[:Cf:][:Cc:][:Z*:]]*)?"</span>
292      <span class="string">"([[:Nd:]]+(?:[[:Po:]][[:Nd:]]+)?)?"</span>
293      <span class="string">"(?(1)"</span>
294         <span class="string">"|(?(2)"</span>
295            <span class="string">"[[:Cf:][:Cc:][:Z*:]]*"</span>
296         <span class="string">")"</span>
297         <span class="string">"[[:Sc:]]"</span>
298      <span class="string">")"</span><span class="special">;</span>
299   <span class="identifier">boost</span><span class="special">::</span><span class="identifier">u32regex</span> <span class="identifier">r</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">make_u32regex</span><span class="special">(</span><span class="identifier">re</span><span class="special">);</span>
300   <span class="identifier">boost</span><span class="special">::</span><span class="identifier">u32regex_token_iterator</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">::</span><span class="identifier">const_iterator</span><span class="special">&gt;</span>
301      <span class="identifier">i</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">make_u32regex_token_iterator</span><span class="special">(</span><span class="identifier">text</span><span class="special">,</span> <span class="identifier">r</span><span class="special">,</span> <span class="number">1</span><span class="special">)),</span> <span class="identifier">j</span><span class="special">;</span>
302   <span class="keyword">while</span><span class="special">(</span><span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">j</span><span class="special">)</span>
303   <span class="special">{</span>
304      <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">*</span><span class="identifier">i</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
305      <span class="special">++</span><span class="identifier">i</span><span class="special">;</span>
306   <span class="special">}</span>
307<span class="special">}</span>
308</pre>
309</div>
310<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
311<td align="left"></td>
312<td align="right"><div class="copyright-footer">Copyright © 1998-2013 John Maddock<p>
313        Distributed under the Boost Software License, Version 1.0. (See accompanying
314        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>)
315      </p>
316</div></td>
317</tr></table>
318<hr>
319<div class="spirit-nav">
320<a accesskey="p" href="unicode_algo.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../icu.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="../mfc_strings.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
321</div>
322</body>
323</html>
324