blob: e4933fe16f8e1eec1bcffa30925d9368ae12768c [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// const value_type& operator*() const;
15
16#include <regex>
17#include <cassert>
18
19int main()
20{
21 {
22 std::regex phone_numbers("\\d{3}-\\d{4}");
23 const char phone_book[] = "555-1234, 555-2345, 555-3456";
24 std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
25 assert(i != std::cregex_iterator());
26 assert((*i).size() == 1);
27 assert((*i).position() == 0);
28 assert((*i).str() == "555-1234");
29 ++i;
30 assert(i != std::cregex_iterator());
31 assert((*i).size() == 1);
32 assert((*i).position() == 10);
33 assert((*i).str() == "555-2345");
34 ++i;
35 assert(i != std::cregex_iterator());
36 assert((*i).size() == 1);
37 assert((*i).position() == 20);
38 assert((*i).str() == "555-3456");
39 ++i;
40 assert(i == std::cregex_iterator());
41 }
Howard Hinnantbbd80862010-08-22 00:45:01 +000042}