Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save keisukeYamagishi/29121c147d70cc42e5b5cae8a52b1187 to your computer and use it in GitHub Desktop.
Save keisukeYamagishi/29121c147d70cc42e5b5cae8a52b1187 to your computer and use it in GitHub Desktop.
Regex_search special symbol
//
// main.cpp
// Seiki
//
// Created by Shichimitoucarashi on 2020/07/12.
// Copyright © 2020 keisukeYamagishi. All rights reserved.
//
#include <iostream>
#include <regex>
using namespace::std;
int main(int argc, const char * argv[]) {
// insert code here...
string tokushu[31] = {"!","\"","+","-","@",">","<","~","$",
"%","&","?","#","\'",":","*","/"," ","(",")","{","}", "|","`","=","","+","^","[","]","_"};
smatch match;
int len = sizeof(tokushu) / sizeof(tokushu[0]);
for( int i = 0; i < len; ++i ){
if(regex_search(tokushu[i], match, regex("[!\"+-@><~$%&?#\'*/ ^(:_;){}¥|`=[\\]]"))){
cout << "matched: " << tokushu[i] << endl;
}else{
cout << tokushu[i] << endl;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment