19,472
社区成员




//凡是?。!后面跟1~1000后面跟半角.的,在?。!后面加回车换行。
//in.txt:
//1.测试。2.测试2?3.测试3!4.测试
//四。5.测试。6.测试6?7.测试3!8.测试
//运行该程序将输出重定向到比如out.txt即可将输出保存到文件out.txt中
#include <iostream>
#include <fstream>
#include <string>
#include <regex>
using namespace std;
int main() {
wifstream wifs("in.txt");
wifs.imbue(locale("chs"));
wstring wstr(L""),wln;
while (wifs) {
getline(wifs,wln);
wstr+=wln;
}
wifs.close();
wcout.imbue(locale("chs"));
wcout << wstr << endl;
wstring rs = L"([?。!])(\\d{1,3}\\.)";
wregex expression(rs);
wstr = regex_replace(wstr, expression, wstring(L"$1\r\n$2"));
wcout << wstr << endl;
return 0;
}
//1.测试。2.测试2?3.测试3!4.测试四。5.测试。6.测试6?7.测试3!8.测试
//1.测试。
//2.测试2?
//3.测试3!
//4.测试四。
//5.测试。
//6.测试6?
//7.测试3!
//8.测试
//