#include<iostream>
#include<stdlib.h>
#include<regex>
#include<vector>
#include<string>
using namespace std;
typedef vector<string> vec_str;
int main() {
vec_str targ;
string _instr;//子串
int opt,num;//opt选择是大小写是否敏感,num为串个数
cin >> _instr >> opt>>num;
for (int i = 0; i < num; ++i) {
string temp;
cin >> temp;
targ.push_back(temp);
}
//cout << regex_match("HiHiHelloHiHi", regex{ "[A-Za-z]*" + _instr + "[A-Za-z]*" }) << endl;
//处理
switch (opt) {
case 1://大小写敏感
for (auto m : targ) {
if (1 == regex_match(m, regex{ "[A-Za-z]*" + _instr + "[A-Za-z]*" })) {
cout << m << endl;
}
}
break;
case 0://大小写不敏感
for (auto m : targ) {
if (1 == regex_match(m, regex{ "[A-Za-z]*" + _instr + "[A-Za-z]*",regex::icase })) {
cout << m << endl;
}
}
break;
}
system("pause");
return 0;
}
CCF计算机软件能力认证试题:201409-3字符串匹配
最新推荐文章于 2024-08-19 12:55:43 发布