Skip to content

Instantly share code, notes, and snippets.

@temoto
Created March 2, 2012 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save temoto/1959644 to your computer and use it in GitHub Desktop.
Save temoto/1959644 to your computer and use it in GitHub Desktop.
#include <pcrecpp.h>
#include <iostream>
int main(int argc, char *argv[]) {
// Don't sync C++ and C I/O
std::ios_base::sync_with_stdio(false);
if (argc < 2) {
std::cerr << "Usage: re_remove REGEX <input" << std::endl;
return 1;
}
const std::string re_src = argv[1];
pcrecpp::RE re(re_src, pcrecpp::RE_Options()
.set_no_auto_capture(true)
.set_utf8(false));
std::string line;
const std::string empty = "";
while (std::getline(std::cin, line)) {
re.GlobalReplace(empty, &line);
std::cout << line << std::endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment