blob: 594c9fb984539f14f0059f4bb63ef4224d35e3eb [file] [log] [blame]
Marshall Clow64befb52015-03-19 17:05:59 +00001// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// The LLVM Compiler Infrastructure
5//
6// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10
11// <regex>
12
13// match_not_eol:
14// The last character in the sequence [first,last) shall be treated as
15// though it is not at the end of a line, so the character "$" in
16// the regular expression shall not match [last,last).
17
18#include <regex>
19#include <cassert>
Marshall Clow64befb52015-03-19 17:05:59 +000020
21int main()
22{
23 {
24 std::string target = "foo";
25 std::regex re("foo$");
26 assert( std::regex_match(target, re));
27 assert(!std::regex_match(target, re, std::regex_constants::match_not_eol));
28 }
29
30 {
31 std::string target = "foo";
32 std::regex re("foo");
33 assert( std::regex_match(target, re));
34 assert( std::regex_match(target, re, std::regex_constants::match_not_eol));
35 }
36
37 {
38 std::string target = "refoo";
39 std::regex re("foo$");
40 assert( std::regex_search(target, re));
41 assert(!std::regex_search(target, re, std::regex_constants::match_not_eol));
42 }
43
44 {
45 std::string target = "refoo";
46 std::regex re("foo");
47 assert( std::regex_search(target, re));
48 assert( std::regex_search(target, re, std::regex_constants::match_not_eol));
49 }
50}