1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 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 #include "test_macros.h" 21 main()22int main() 23 { 24 { 25 std::regex phone_numbers("\\d{3}-\\d{4}"); 26 const char phone_book[] = "555-1234, 555-2345, 555-3456"; 27 std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers); 28 assert(i != std::cregex_iterator()); 29 assert(i->size() == 1); 30 assert(i->position() == 0); 31 assert(i->str() == "555-1234"); 32 ++i; 33 assert(i != std::cregex_iterator()); 34 assert(i->size() == 1); 35 assert(i->position() == 10); 36 assert(i->str() == "555-2345"); 37 ++i; 38 assert(i != std::cregex_iterator()); 39 assert(i->size() == 1); 40 assert(i->position() == 20); 41 assert(i->str() == "555-3456"); 42 ++i; 43 assert(i == std::cregex_iterator()); 44 } 45 } 46