164befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow// -*- C++ -*- 264befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow//===----------------------------------------------------------------------===// 364befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow// 464befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow// The LLVM Compiler Infrastructure 564befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow// 664befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow// This file is dual licensed under the MIT and the University of Illinois Open 764befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow// Source Licenses. See LICENSE.TXT for details. 864befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow// 964befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow//===----------------------------------------------------------------------===// 1064befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow 1164befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow// <regex> 1264befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow 1364befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow// match_not_eol: 1464befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow// The last character in the sequence [first,last) shall be treated as 1564befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow// though it is not at the end of a line, so the character "$" in 1664befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow// the regular expression shall not match [last,last). 1764befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow 1864befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow#include <regex> 1964befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow#include <cassert> 2064befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow 2164befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clowint main() 2264befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow{ 2364befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow { 2464befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow std::string target = "foo"; 2564befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow std::regex re("foo$"); 2664befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow assert( std::regex_match(target, re)); 2764befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow assert(!std::regex_match(target, re, std::regex_constants::match_not_eol)); 2864befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow } 2964befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow 3064befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow { 3164befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow std::string target = "foo"; 3264befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow std::regex re("foo"); 3364befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow assert( std::regex_match(target, re)); 3464befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow assert( std::regex_match(target, re, std::regex_constants::match_not_eol)); 3564befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow } 3664befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow 3764befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow { 3864befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow std::string target = "refoo"; 3964befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow std::regex re("foo$"); 4064befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow assert( std::regex_search(target, re)); 4164befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow assert(!std::regex_search(target, re, std::regex_constants::match_not_eol)); 4264befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow } 4364befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow 4464befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow { 4564befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow std::string target = "refoo"; 4664befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow std::regex re("foo"); 4764befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow assert( std::regex_search(target, re)); 4864befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow assert( std::regex_search(target, re, std::regex_constants::match_not_eol)); 4964befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow } 5064befb5bc5b5aaec6717c931396990eb58ecd626Marshall Clow} 51