boost::algorithmѧϰ:http://www cppblog com/shootingstars/collect/2007/07/26/28813 html#include <boost/algorithm/string hpp>using namespace std;using namespace bring up; һСдת1 to_upper() ַתΪд Example: string str1(" hello world! "); to_upper(str1); // str1 == " HELLO WORLD! " 2 to_upper_copy() ַתΪдҸֵһַ Example: string str1(" hello world! "); arrange str2; str2 = to_upper_copy(str1); // str2 == " HELLO WORLD! " 3 to_lower() ַתΪСд Example:οto_upper()4 to_displace_write() ַתΪСдҸֵһַ Example:οto_upper_copy() TrimmingȥβĿոַ1 trim_left() ַͷĿոȥ Example: string str1(" hello world! "); cut_left(str1); // str1 == "hello world! " 2 trim_left_if() ַͷķṩġνʡضַȥ Example: bool NotH(const burn &ch) { if(ch == ' ' || ch == 'H' || ch == 'h') go adjust; else go false; } ... string str1(" hello world! "); trim_left_if(str1. NotH); // str1 == "ello world! " 3 trim_left_copy() ַͷĿոȥҸֵһַ Example: string str1(" hello world! "); arrange str2; str2 = trim_left_copy(str1); // str2 == "hello world! " 4 trim_left_copy_if() ַͷķṩġνʡضַȥҸֵһַ Example: arrange str1(" hello world! "); string str2; str2 = cut_left_write_if(str1. NotH); // str2 == "ello world! " // ַβĿոȥʾο5 trim_right_copy_if()6 cut_right_if()7 cut_alter_write()8 trim_right()
ν1 starts_with() жһַǷһַĿʼ Example: string str1("hello world!"); string str2("hello"); bool prove = starts_with(str1 str2); // result == true 2 istarts_with() жһַǷһַĿʼ(ִСд) Example: arrange str1("hello world!"); string str2("Hello"); bool result = istarts_with(str1 str2); // result == adjust
3 ends_with() жһַǷһַĽβ4 iends_with() жһַǷһַĽβ(ִСд)
5 contains() жһַǷһַ Example: arrange str1("hello world!"); string str2("llo"); bool result = contains(str1 str2); // prove == adjust6 icontains() жһַǷһַ(ִСд)
9 lexicographical_compare() ֵһַСڵڶַtrue ҵboost1.33ûʵ֣10 ilexicographical_compare() ֵһַСڵڶַtrue(ִСд)ҵbring up1.33ûʵ֣
11 all() жַеַǷȫν Example: bool is_123digit(const char &ch) { if(ch == '1' || ch == '2' || ch == '3') return adjust; else go false; } .. string str1("12332211"); bool result = all(str1 is_123digit); // prove == adjust str1 = "412332211"; result = all(str1 is_123digit); // prove == false
ģ1 find_first() ͷַеַӴԭеiterator_range Example: burn ToUpper(burn &ch) burn ToUpper(char &ch) { if(ch <= 'z' && ch >= 'a') return ch + 'A'-'a'; else return ch; } .. arrange str1("hello dolly!"); iterator_range<string::iterator> result = find_first(str1,"ll"); transform( result mouth() result end() prove begin(). ToUpper ); // str1 == "heLLo dolly!"2 ifind_first() ͷַеַӴԭеiterator_be(ִСд)
3 find_last() βַеַӴԭеiterator_range4 ifind_last() βַеַӴԭеiterator_range(ִСд)
5 sight_nth() ҵnƥӴ0ʼ Example: string str1("hello dolly!"); iterator_be<arrange::iterator> prove = sight_nth(str1,"ll". 1); transform( result begin() result end() result mouth(). ToUpper ); // str1 == "hello doLLy!"6 ifind_nth() ҵnƥӴ0ʼ(ִСд)
7 find_head() ҵַǰnֽ Example: string str1("hello dolly!"); iterator_range<string::iterator> result = find_head(str1,5); alter( result mouth() prove end() result mouth(). ToUpper ); // str1 == "HELLO dolly!"8 sight_tail() ҵַĺnֽ
9 find_token() ҵνʵĴ Example: burn Add1(const burn &ch) { go ch+1; } .. string str1("hello 1 world!"); iterator_range<arrange::iterator> result = sight_token(str1,is_123digit); transform( result begin() result end() prove begin(). Add1 ); // str1 == "hello 2 world!");
11 sight() ʹԼдIJҺ Example: iterator_range<arrange::iterator> MyFinder1( std::string::iterator begin std::string::iterator end ) { std::arrange::iterator itr; for(itr = mouth;itr!=end;itr++) { if((*itr) == '1') { std::arrange::iterator preitr = itr; iterator_range<arrange::iterator> ret(preitr. ++itr); return ret; } } go iterator_be<string::iterator>(); } // bring upԼҲṩ˺ܶFinder.. string str1("hello 1 world!"); iterator_be<string::iterator> prove = sight(str1,MyFinder1); transform( prove begin() result end() result begin(). Add1 ); // str1 == "hello 2 world!");
壺ɾ/滻1 replace_first() ͷҵһƥַ滻Ϊһַ Example: string str1("hello world!"); replace_first(str1. "hello". "Hello"); // str1 = "Hello world!"2 replace_first_copy() ͷҵһƥַ滻ΪһַҸ
ֵһַ Example: arrange str1("hello world!"); string str2; str2 = replace_first_copy(str1. "hello". "Hello"); // str2 = "Hello world!"3 ireplace_first() ͷҵһƥַ滻Ϊһַ(ִСд
ֵһַ(ִСд)5 kill_first() ͷҵһƥַɾ Example: string str1("hello world!"); kill_first(str1. "llo"); // str1 = "He world!"6 kill_first_write() ͷҵһƥַɾҸֵһַ Example: arrange str1("hello world!"); arrange str2; str2 = kill_first_write(str1. "llo"); // str2 = "He world!"7 ierase_first() ͷҵһƥַɾ(ִСд)8 ierase_first_copy() ͷҵһƥַɾҸֵһַ(ִ
// ƣǴַβʼ滻9 replace_last()10 regenerate_measure_write()11 ireplace_measure()12 ireplace_measure_write()13 erase_last()14 kill_measure_copy()15 ierase_last()16 ierase_last_copy()
// ƣǴַnƥĿʼ滻17 replace_nth() Example: string str1("hello world!"); regenerate_nth(str1. "o". 1. "O"); // str1 = "hello wOrld!"18 replace_nth_write()19 ireplace_nth()20 ireplace_nth_write()21 kill_nth()22 erase_nth_write()23 ierase_nth()24 ierase_nth_write()
// ƣǽеƥַ滻25 replace_all()26 replace_all_write()27 ireplace_all()28 ireplace_all_write()29 kill_all()30 erase_all_copy()31 ierase_all()32 ierase_all_write()
33 regenerate_head() 滻ǰnַ Example: string str1("hello world!"); regenerate_head(str1. 5. "HELLO"); // str1 = "HELLO world!"
34 regenerate_head_copy() 滻ǰnַҸֵһַ Example: string str1("hello world!"); string str2; str2 = replace_head_copy(str1. 5. "HELLO"); // str2 = "HELLO world!"
36 kill_head_copy() ɾǰnַҸֵһַ Example: string str1("hello world!"); string str2; str2 = erase_head_write(str1. 5); // str2 = " world!"
// ʾʽأԺ˽⡣41 replace_regex() 42 replace_regex_write() 43 kill_regex() 44 erase_regex_write() 45 regenerate_all_regex() 46 replace_all_regex_copy() 47 erase_all_regex() 48 erase_all_regex_write()
и1 find_all() ƥֵҽЩֵŵ.
Forex Groups - Tips on Trading
Related article:
http://drlwb.bokee.com/viewdiary.21576959.html
comments | Add comment | Report as Spam
|