blob: c9fc7a3cd1cc8b0a67a122e7fb447ab5c5e7f6b8 [file] [log] [blame]
Howard Hinnanta712c722010-08-16 20:21:16 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnanta712c722010-08-16 20:21:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <regex>
11
12// class regex_iterator<BidirectionalIterator, charT, traits>
13
14// regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
15// const regex_type& re,
16// regex_constants::match_flag_type m = regex_constants::match_default);
17
18#include <regex>
19#include <cassert>
20
21int main()
22{
23 {
24 std::regex phone_numbers("\\d{3}-\\d{4}");
25 const char phone_book[] = "555-1234, 555-2345, 555-3456";
26 std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
27 assert(i != std::cregex_iterator());
28 assert(i->size() == 1);
29 assert(i->position() == 0);
30 assert(i->str() == "555-1234");
31 ++i;
32 assert(i != std::cregex_iterator());
33 assert(i->size() == 1);
34 assert(i->position() == 10);
35 assert(i->str() == "555-2345");
36 ++i;
37 assert(i != std::cregex_iterator());
38 assert(i->size() == 1);
39 assert(i->position() == 20);
40 assert(i->str() == "555-3456");
41 ++i;
42 assert(i == std::cregex_iterator());
43 }
Howard Hinnanta8d77592010-08-18 00:13:08 +000044}