sed -i -- 's/PATTERN/REPLACEMENT/g' *
- The
-i
means "in-place" - The
--
tellssed
that this is the end of the options. Otherwise, it might interpret hyphens in the script as options
sed -i -- 's/PATTERN/REPLACEMENT/g' *
-i
means "in-place"--
tells sed
that this is the end of the options. Otherwise, it might interpret hyphens in the script as optionsSay we have the following string:
std::string str = "The quick brown fox jumps over the lazy dog";
And we want to find "fox"
Here are three methods:
std::string::find()
boost::contains()
pystring::find()
std::string::find
bool found = str.find("fox") != str.npos;
This returns an iterator pointing at the beginning of the substring if found, or std::string::npos
otherwise.
boost::contains
#include <boost/algorithm/string/predicate.hpp> found = boost::contains(str, "fox");
This has the advantage of returning a boolean.
Reference: Function contains
pystring::find
#include <pystring.h> found = pystring::find(str, "fox") != -1;
Reference: imageworks/pystring