main.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* main.cpp :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@gmail.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2025/07/15 18:21:32 by bchanot #+# #+# */
  9. /* Updated: 2025/07/15 19:35:30 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include <iostream>
  13. #include <fstream>
  14. #include <regex>
  15. int main(int ac, char **av) {
  16. std::string line;
  17. if (ac < 3)
  18. return 1;
  19. std::ifstream ifs(av[1]);
  20. std::string out_name = av[1];
  21. std::ofstream ofs(out_name.append(".replace"));
  22. while (std::getline(ifs, line)) {
  23. ofs << std::regex_replace(line, std::regex(av[2]), av[3]) << std::endl;
  24. }
  25. ifs.close();
  26. ofs.close();
  27. return 0;
  28. }