How to replace Boolean with bool using RegEx in C++

1 Answer

0 votes
#include <iostream>
#include <string>
#include <regex>

int main() {
    std::string code = "Boolean flag = true; // Boolean type";
    std::regex pattern("\\bBoolean\\b");

    std::string result = std::regex_replace(code, pattern, "bool");

    std::cout << result << std::endl;
}


/*
run:

bool flag = true; // bool type

*/

 



answered 8 hours ago by avibootz

Related questions

2 answers 248 views
248 views asked Aug 30, 2016 by avibootz
3 answers 256 views
256 views asked Jan 2, 2017 by avibootz
1 answer 246 views
1 answer 239 views
...