C++/CPP: Search and Replace in String

On October 16, 2010, in Coding, CPP, by Dipin Krishna

My CPP function for search and replace in string is given below: string search_replace( string String, string searchString, string replaceString, string::size_type pos = 0) {   while ( (pos = String.find(searchString, pos)) != string::npos ) { String.replace( pos, searchString.size(), replaceString ); pos += replaceString.size(); } return String; } Sample program using it. /* * searchreplace.cpp [...]

Tagged with:  

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

Unlimited Domain Hosting Unlimited Domain Hosting
IP Address :
Country : United States
Featured FREE Resource: