1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // class regex_token_iterator<BidirectionalIterator, charT, traits>
13 // regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
14 // const regex_type& re, int submatch = 0,
15 // regex_constants::match_flag_type m =
16 // regex_constants::match_default);
20 #include "test_macros.h"
25 std::regex
phone_numbers("\\d{3}-\\d{4}");
26 const char phone_book
[] = "start 555-1234, 555-2345, 555-3456 end";
27 std::cregex_token_iterator
i(std::begin(phone_book
), std::end(phone_book
)-1,
29 assert(i
!= std::cregex_token_iterator());
30 assert(i
->str() == "start ");
32 assert(i
!= std::cregex_token_iterator());
33 assert(i
->str() == ", ");
35 assert(i
!= std::cregex_token_iterator());
36 assert(i
->str() == ", ");
38 assert(i
!= std::cregex_token_iterator());
39 assert(i
->str() == " end");
41 assert(i
== std::cregex_token_iterator());
44 std::regex
phone_numbers("\\d{3}-\\d{4}");
45 const char phone_book
[] = "start 555-1234, 555-2345, 555-3456 end";
46 std::cregex_token_iterator
i(std::begin(phone_book
), std::end(phone_book
)-1,
48 assert(i
!= std::cregex_token_iterator());
49 assert(i
->str() == "555-1234");
51 assert(i
!= std::cregex_token_iterator());
52 assert(i
->str() == "555-2345");
54 assert(i
!= std::cregex_token_iterator());
55 assert(i
->str() == "555-3456");
57 assert(i
== std::cregex_token_iterator());
60 std::regex
phone_numbers("\\d{3}-(\\d{4})");
61 const char phone_book
[] = "start 555-1234, 555-2345, 555-3456 end";
62 std::cregex_token_iterator
i(std::begin(phone_book
), std::end(phone_book
)-1,
64 assert(i
!= std::cregex_token_iterator());
65 assert(i
->str() == "1234");
67 assert(i
!= std::cregex_token_iterator());
68 assert(i
->str() == "2345");
70 assert(i
!= std::cregex_token_iterator());
71 assert(i
->str() == "3456");
73 assert(i
== std::cregex_token_iterator());