9
मैं इन वैरिएबल नहीं:बूस्ट नियमित अभिव्यक्ति विधि का उपयोग कैसे करें?
boost::regex re //regular expression to use
std::string stringToChange //replace this string
std::string newValue //new value that is going to replace the stringToChange depending on the regex.
मैं केवल केवल यह की पहली आवृत्ति बदलना चाहते हैं।
धन्यवाद फलास।
संपादित करें: मैं इस पाया है:
boost::regex_replace(stringToChange, re, boost::format_first_only);
लेकिन यह कहते समारोह मौजूद नहीं है, मेरा अनुमान है कि मानकों को पल में सही नहीं हैं।
#include <iostream>
#include <string>
#include <boost/regex.hpp>
int main(){
std::string str = "hellooooooooo";
std::string newtext = "o Bob";
boost::regex re("ooooooooo");
std::cout << str << std::endl;
std::string result = boost::regex_replace(str, re, newtext);
std::cout << result << std::endl;
}
आउटपुट
hellooooooooo
हैलो बॉब
सुनिश्चित करें कि आप <boost/regex.hpp>
सहित कर रहे हैं:
यह एक वैध कार्य नहीं है। –