如果在字符串中找到单词,我想将其替换int, float, char, bool, main, cin, cout, if, else, else if, for, while, clrscr, getch, do, void
为""
(例如删除)。
所以如果我有ff:
str = "main(){ clrscr(); couts<<"wrong"; cout<<"right"; }"
更换后应该是:
str = "(){ (); couts<<"wrong"; <<"right"; }"
到目前为止,我尝试过的是(当然是错误的):
str = str.replace(/\s+(?:int|char|bool|main|float)/, "");//summarized