Created
July 12, 2020 15:10
-
-
Save keisukeYamagishi/29121c147d70cc42e5b5cae8a52b1187 to your computer and use it in GitHub Desktop.
Regex_search special symbol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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