摘要:
正则表示主要用于查找一系列符合规则的对象,而我们之前的查找是对某一特定的字符串进行查找。#include #include #include #include using namespace std;using namespace boost;using namespace boost::xpressive;int main(){ string str; cregex reg = cregex::compile("a.c"); if (regex_match("abc",reg)) { cout << "Ok"<&l 阅读全文
摘要:
string_algo是用于处理字符串查找,替换,转换等一系列的字符串算法前缀i:表示大小写不敏感后缀_copy:表示不变动输入,返回处理结果的拷贝后缀_if:表示算法需要一个判断式的谓词函数对象。#include #include #include #include using namespace std;using namespace boost;int main(){ string str("readme.txt"); if (ends_with(str,"txt"))//判断后缀 { cout v(str.begin(),str.end()); 阅读全文
摘要:
C++标准库中字符串转数值使用函数atoi(),数值转字符串使用printf系列函数。boost中使用转换函数操作符lexical_cast进行转换,实际上是模板函数。自定义类型,要进行转换必须支持输入输出操作符>。#include #include using namespace std;using namespace boost;int main()try{ int x = lexical_cast("100"); long y = lexical_cast("2000L"); float pai = lexical_cast("3. 阅读全文