CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <bits/stdc++.h>
using namespace std;
int main() {
const auto input = "Some people, when"
" confronted with a problem, think"
" \"I know, I'll use regular "
"expressions.\""s;
smatch sm;
cout << input << endl;
if (regex_match(
input,
sm,
regex("(.*)\".*\\breg.*\\bex.*\"\\s*$")
)
) {
const auto capture = sm[1].str();
cout << '\t' << capture << endl;
if(regex_search(
capture,
sm,
regex("(a|d+)\\s+problems?")
)
) {
const auto count = sm[1]=="a"s ?
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run