| 1 |
//===----------------------------------------------------------------------===// |
| 2 |
// |
| 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 |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
// <regex> |
| 10 |
|
| 11 |
// match_not_bol: |
| 12 |
// The first character in the sequence [first,last) shall be treated as |
| 13 |
// though it is not at the beginning of a line, so the character ^ in the |
| 14 |
// regular expression shall not match [first,first). |
| 15 |
|
| 16 |
#include <regex> |
| 17 |
#include <cassert> |
| 18 |
#include "test_macros.h" |
| 19 |
|
| 20 |
int main(int, char**) |
| 21 |
{ |
| 22 |
{ |
| 23 |
std::string target = "foo"; |
| 24 |
std::regex re("^foo"); |
| 25 |
assert( std::regex_match(target, re)); |
| 26 |
assert(!std::regex_match(target, re, std::regex_constants::match_not_bol)); |
| 27 |
} |
| 28 |
|
| 29 |
{ |
| 30 |
std::string target = "foo"; |
| 31 |
std::regex re("foo"); |
| 32 |
assert( std::regex_match(target, re)); |
| 33 |
assert( std::regex_match(target, re, std::regex_constants::match_not_bol)); |
| 34 |
} |
| 35 |
|
| 36 |
{ |
| 37 |
std::string target = "fooby"; |
| 38 |
std::regex re("^foo"); |
| 39 |
assert( std::regex_search(target, re)); |
| 40 |
assert(!std::regex_search(target, re, std::regex_constants::match_not_bol)); |
| 41 |
} |
| 42 |
|
| 43 |
{ |
| 44 |
std::string target = "fooby"; |
| 45 |
std::regex re("foo"); |
| 46 |
assert( std::regex_search(target, re)); |
| 47 |
assert( std::regex_search(target, re, std::regex_constants::match_not_bol)); |
| 48 |
} |
| 49 |
|
| 50 |
return 0; |
| 51 |
} |