[RISCV] Add MIPS P8700 processor (#119882)
[llvm-project.git] / libcxx / test / std / re / re.alg / re.alg.replace / test6.pass.cpp
blob66a910172c4972c21a25de508845fa8e51932814
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 //===----------------------------------------------------------------------===//
9 // <regex>
11 // template <class traits, class charT>
12 // basic_string<charT>
13 // regex_replace(const charT* s,
14 // const basic_regex<charT, traits>& e,
15 // const charT* fmt,
16 // regex_constants::match_flag_type flags =
17 // regex_constants::match_default);
19 #include <regex>
20 #include <cassert>
21 #include "test_macros.h"
23 int main(int, char**)
26 std::regex phone_numbers("\\d{3}-\\d{4}");
27 const char phone_book[] = "555-1234, 555-2345, 555-3456";
28 std::string r = std::regex_replace(phone_book, phone_numbers,
29 "123-$&");
30 assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
33 std::regex phone_numbers("\\d{3}-\\d{4}");
34 const char phone_book[] = "555-1234, 555-2345, 555-3456";
35 std::string r = std::regex_replace(phone_book, phone_numbers,
36 "123-$&",
37 std::regex_constants::format_sed);
38 assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
41 std::regex phone_numbers("\\d{3}-\\d{4}");
42 const char phone_book[] = "555-1234, 555-2345, 555-3456";
43 std::string r = std::regex_replace(phone_book, phone_numbers,
44 "123-&",
45 std::regex_constants::format_sed);
46 assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
49 std::regex phone_numbers("\\d{3}-\\d{4}");
50 const char phone_book[] = "555-1234, 555-2345, 555-3456";
51 std::string r = std::regex_replace(phone_book, phone_numbers,
52 "123-$&",
53 std::regex_constants::format_no_copy);
54 assert(r == "123-555-1234123-555-2345123-555-3456");
57 std::regex phone_numbers("\\d{3}-\\d{4}");
58 const char phone_book[] = "555-1234, 555-2345, 555-3456";
59 std::string r = std::regex_replace(phone_book, phone_numbers,
60 "123-$&",
61 std::regex_constants::format_first_only);
62 assert(r == "123-555-1234, 555-2345, 555-3456");
65 std::regex phone_numbers("\\d{3}-\\d{4}");
66 const char phone_book[] = "555-1234, 555-2345, 555-3456";
67 std::string r = std::regex_replace(phone_book, phone_numbers,
68 "123-$&",
69 std::regex_constants::format_first_only |
70 std::regex_constants::format_no_copy);
71 assert(r == "123-555-1234");
74 return 0;