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 //===----------------------------------------------------------------------===//
12 // --first is a valid iterator position. When this flag is set the flags
13 // match_not_bol and match_not_bow shall be ignored by the regular
14 // expression algorithms (30.11) and iterators (30.12)
20 int main(int, char**) {
22 auto str1_scnd
= str1
+ 1;
23 // Assert that match_prev_avail disables match_not_bol and this matches
24 assert(regex_match(str1
+ 1, str1
+ 2, regex("^a"),
25 regex_constants::match_not_bol
|
26 regex_constants::match_prev_avail
));
27 // Manually passing match_prev_avail defines that --str1 is a valid position
28 assert(regex_match(str1_scnd
, regex("a"),
29 regex_constants::match_not_bol
|
30 regex_constants::match_prev_avail
));
32 //Assert that match_prev_avail disables match_not_bow and this matches
33 assert(regex_search(str1
, regex("\\ba")));
34 assert(regex_match(str1
+ 1, str1
+ 2, regex("\\ba\\b"),
35 regex_constants::match_not_bow
|
36 regex_constants::match_prev_avail
));
37 assert(regex_search(str1_scnd
, regex("\\ba"),
38 regex_constants::match_not_bow
|
39 regex_constants::match_prev_avail
));
41 //Assert that match_prev_avail disables both match_not_bow and match_not_bol
42 assert(regex_match(str1
+ 1, str1
+ 2, regex("^a"),
43 regex_constants::match_not_bol
|
44 regex_constants::match_not_bow
|
45 regex_constants::match_prev_avail
));
46 assert(regex_match(str1_scnd
, regex("\\ba"),
47 regex_constants::match_not_bol
|
48 regex_constants::match_not_bow
|
49 regex_constants::match_prev_avail
));
53 string::iterator Start
= S
.begin() + 1;
54 string::iterator End
= S
.end();
55 assert(regex_search(Start
, End
, regex("^cd")));
58 !regex_search(Start
, End
, regex("^cd"), regex_constants::match_not_bol
));
59 assert(!regex_search(Start
, End
, regex(".*\\bcd\\b"),
60 regex_constants::match_not_bow
));
61 assert(!regex_search(Start
, End
, regex("^cd"),
62 regex_constants::match_not_bol
|
63 regex_constants::match_not_bow
));
64 assert(!regex_search(Start
, End
, regex(".*\\bcd\\b"),
65 regex_constants::match_not_bol
|
66 regex_constants::match_not_bow
));
68 assert(regex_search(Start
, End
, regex("^cd"),
69 regex_constants::match_prev_avail
));
71 assert(regex_search(Start
, End
, regex("^cd"),
72 regex_constants::match_not_bol
|
73 regex_constants::match_prev_avail
));
74 assert(regex_search(Start
, End
, regex("^cd"),
75 regex_constants::match_not_bow
|
76 regex_constants::match_prev_avail
));
77 assert(regex_match(Start
, End
, regex("\\bcd\\b"),
78 regex_constants::match_not_bol
|
79 regex_constants::match_not_bow
|
80 regex_constants::match_prev_avail
));