How to match the $ special character using regular expression in C++

1 Answer

0 votes
#include <iostream>
#include <regex>
 
int main() {
    std::regex pattern("\\$");
    std::string s = "It's only $10.00 today";
 
    bool match = std::regex_search(s, pattern);
     
    std::cout << match << std::endl;
 
    return 0;
}
 
 
 
/*
run:
 
1
 
*/

 



answered Feb 16, 2025 by avibootz
edited Feb 16, 2025 by avibootz
...