brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 73158dc Raw
41 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <regex>10 11// template <class BidirectionalIterator, class Allocator, class charT, class traits>12//     bool13//     regex_search(BidirectionalIterator first, BidirectionalIterator last,14//                  match_results<BidirectionalIterator, Allocator>& m,15//                  const basic_regex<charT, traits>& e,16//                  regex_constants::match_flag_type flags = regex_constants::match_default);17 18#include <regex>19#include <cassert>20#include "test_macros.h"21 22int main(int, char**)23{24    // Iterating over /^a/ should yield one instance at the beginning25    // of the text.26 27    const char *text = "aaa\naa";28    std::regex re("^a");29    std::cregex_iterator it(text, text+6, re);30    std::cregex_iterator end = std::cregex_iterator();31 32    assert(it->str() == "a");33    assert(it->position(0) == 0);34    assert(it->length(0) == 1);35 36    ++it;37    assert(it == end);38 39  return 0;40}41