当前位置: 首页 > news >正文

html颜色代码上海关键词seo

html颜色代码,上海关键词seo,html5 + css3 网站,南京制作网架厂家文章目录 1.判断1.1.equals1.2.all1.3.starts_with1.4.ends_with1.5.contains 2.大小写转换3.字符串删除4.字符串替换5.字符串查找6.字符串修剪7.字符串分割8.字符串合并9.总结 1.判断 判别式函数和分类函数大多数都是以is_开头,这些函数如下: 判别式函…

文章目录

    • 1.判断
      • 1.1.equals
      • 1.2.all
      • 1.3.starts_with
      • 1.4.ends_with
      • 1.5.contains
    • 2.大小写转换
    • 3.字符串删除
    • 4.字符串替换
    • 5.字符串查找
    • 6.字符串修剪
    • 7.字符串分割
    • 8.字符串合并
    • 9.总结

1.判断

判别式函数和分类函数大多数都是以is_开头,这些函数如下:
判别式函数包括:is_equal(等于)、is_less(小于)、is_not_greater(不大于)、lexicographical_compare(根据顺序检测一个字符串是否小于另一个)、starts_with(检测一个字符串是否是另一个的前缀)、ends_with(检测一个字符串是否是另一个的后缀)、contains(包含)、equals(相等)、all(检测一个字符串中的所有元素是否满足指定的判别式)。

分类函数:is_space、is_alnum(字符和数字)、is_alpha(字母)、is_cntrl(控制符)、is_digit(十进制)、is_graph(图形字符)、is_lower(小写)、is_upper(大写)、is_print(可打印字符)、is_punct(标点符号)、is_xdigit(十六进制)、is_any_of(是否是序列中的任意字符)、if_from_range(是否位于指定区间,包括两头)

1.1.equals

#include <boost/algorithm/string.hpp>
assert(boost::equals("boost", "boost"));
assert(!boost::equals("boost", "BOOST"));
assert(boost::iequals("boost", "BOOST"));

1.2.all

all , 如果它的所有元素满足一个给定的通过判断式描述的条件,则这个条件式成立。

assert(boost::all("\x20\t\n\r", boost::is_space()));
assert(boost::all("\x20\t\n\r", boost::is_classified(std::ctype_base::space)));
assert(boost::all("\x20\t\n\r", boost::is_any_of("\x20\t\n\r")));
assert(boost::all("abcde", boost::is_from_range('a', 'e')));
assert(boost::all("abcde", boost::is_from_range('a', 'z')));
assert(!boost::all("abcde", boost::is_from_range('b', 'c')));
assert(boost::all("abc __ de", boost::is_from_range('a', 'z') || boost::is_space() || boost::is_any_of("_")));

1.3.starts_with

assert(boost::starts_with("boost_python-vc100-mt-1_49.dll", "boost"));
assert(!boost::starts_with("boost_python-vc100-mt-1_49.dll", "BOOST"));
assert(boost::istarts_with("boost_python-vc71-mt-1_33.dll", "BOOST"));

1.4.ends_with

assert(boost::ends_with("boost_python-vc100-mt-1_49.dll", ".dll"));
assert(!boost::ends_with("boost_python-vc100-mt-1_49.dll", ".DLL"));
assert(boost::iends_with("boost_python-vc100-mt-1_49.dll", ".DLL"));

1.5.contains

assert(boost::contains("boost_python-vc100-mt-1_49.dll", "python"));
assert(!boost::contains("boost_python-vc100-mt-1_49.dll", "PYTHON"));
assert(boost::icontains("boost_python-vc100-mt-1_49.dll", "PYTHON"));

is_space: 字符是否为空格
is_alnum: 字符是否为字母和数字字符
is_alpha: 字符是否为字母
is_cntrl: 字符是否为控制字符
is_digit: 字符是否为十进制数字
is_graph: 字符是否为图形字符
is_lower: 字符是否为小写字符
is_print: 字符是否为可打印字符
is_punct: 字符是否为标点符号字符
is_upper: 字符是否为大写字符
is_xdigit: 字符是否为十六进制数字
is_any_of: 字符是否是参数字符序列中的任意字符
is_from_range 字符是否位于指定区间内,即from <= ch <= to

2.大小写转换

主要有如下API:
to_lower_copy:将原来字符串,转换为小写字符串,并返回新的字符串,原来字符串不改变。
to_upper_copy:将原来字符串,转换为大写字符串,并返回新的字符串,原来字符串不改变。
to_lower:将原来字符串,转换为小写字符串,原来字符串改变。
to_upper:将原来字符串,转换为大写字符串,原来字符串改变。

3.字符串删除

boost库提供了众多的字符串删除函数,并且提供了很多版本供使用,例如以i开头的用来区分大小写敏感、以_copy结尾的以不改变原来的字符串等,以满足使用者不同的需求。

erase_first:删除在字符串中第一个出现的字符串。
erase_last:删除在字符串中最后一个出现的字符串。
erase_nth:删除在字符串中第n个出现的字符串。
erase_all:删除在字符串中所有出现的字符串。
erase_head:删除输入的开头。
erase_tail:删除输入的结尾。

#include <iostream>
#include <boost/algorithm/string.hpp>int main()
{std::string tmpStrErase = "Hello!Hello!I'm ISmileLi!Hello!Hello!I'm ISmileLi!";std::cout << "tmpStrErase:" << tmpStrErase << std::endl;boost::algorithm::erase_first(tmpStrErase, "Hello");std::cout << "tmpStrErase:" << tmpStrErase << std::endl;std::string tmpEraseLastStr = boost::algorithm::erase_last_copy(tmpStrErase, "Hello");std::cout << "tmpStrErase:" << tmpStrErase << std::endl;std::cout << "tmpEraseLastStr:" << tmpEraseLastStr << std::endl;boost::algorithm::erase_nth(tmpStrErase, "Hello", 2);std::cout << "tmpStrErase:" << tmpStrErase << std::endl;boost::algorithm::erase_all(tmpStrErase, "Hello");std::cout << "tmpStrErase:" << tmpStrErase << std::endl;std::string tmpEraseHeadCopyStr = boost::algorithm::erase_head_copy(tmpStrErase, 5);std::cout << "tmpStrErase:" << tmpStrErase << std::endl;std::cout << "tmpEraseHeadCopyStr:" << tmpEraseHeadCopyStr << std::endl;std::cout << "Hello World!\n";getchar();
}

4.字符串替换

boost库提供了众多的字符串替换函数,并且提供了很多版本供使用,例如以i开头的用来区分大小写敏感、以_copy结尾的以不改变原来的字符串等,以满足使用者不同的需求。

boost库提供的替换函数如下:
replace_first:替换在字符串中第一个出现的字符串。
replace_last:替换在字符串中最后一个出现的字符串。
replace_nth:替换在字符串中第n个出现的字符串。
replace_all:替换在字符串中所有出现的字符串。
replace_head:替换输入的开头。
replace_tail:替换输入的结尾。

#include <iostream>
#include <boost/algorithm/string.hpp>int main()
{std::cout << "-------------------boost库字符串替换------------------" << std::endl;std::string tmpStrReplace = "HELLO!HELLO!I'm ISmileLi!HELLO!HELLO!I'm ISmileLi!";std::cout << "-------------------打印原来字符串的值------------------" << std::endl;std::cout << "tmpStrReplace:" << tmpStrReplace << std::endl;boost::algorithm::replace_first(tmpStrReplace, "HELLO", "hello");std::cout << "-------------------替换第一个字符串后------------------" << std::endl;std::cout << "tmpStrReplace:" << tmpStrReplace << std::endl;std::string tmpReplaceLastStr = boost::algorithm::replace_last_copy(tmpStrReplace, "HELLO", "hello");std::cout << "-------------------替换最后一个字符串后------------------" << std::endl;std::cout << "tmpStrReplace:" << tmpStrReplace << std::endl;std::cout << "tmpReplaceLastStr:" << tmpReplaceLastStr << std::endl;boost::algorithm::replace_nth(tmpStrReplace, "HELLO", 2, "hello");std::cout << "-------------------替换第2个字符串后------------------" << std::endl;std::cout << "tmpStrReplace:" << tmpStrReplace << std::endl;boost::algorithm::replace_all(tmpStrReplace, "HELLO", "hello");std::cout << "-------------------替换所有出现的字符串后------------------" << std::endl;std::cout << "tmpStrReplace:" << tmpStrReplace << std::endl;std::string tmpReplaceTailCopyStr = boost::algorithm::replace_tail_copy(tmpStrReplace, 5, "hello");std::cout << "-------------------替换结尾出现的几个字符串后------------------" << std::endl;std::cout << "tmpStrReplace:" << tmpStrReplace << std::endl;std::cout << "tmpReplaceHeadCopyStr:" << tmpReplaceTailCopyStr << std::endl;std::cout << "Hello World!\n";getchar();
}

5.字符串查找

boost库提供了众多的字符串查找函数,并且提供了很多版本供使用,例如以i开头的用来区分大小写敏感的以不改变原来的字符串等,没有_copy版本,以满足使用者不同的需求。

boost库提供的查找函数如下:
find_first:查找在字符串中第一个出现的字符串。
find_last:查找在字符串中最后一个出现的字符串。
find_nth:查找在字符串中第n个出现的字符串。
find_head:查找输入的开头第N个子串。
find_tail:查找输入的结尾第N个子串。

#include <iostream>
#include <boost/algorithm/string.hpp>int main()
{std::cout << "-------------------boost库字符串查找------------------" << std::endl;std::string tmpStrFind = "HELLO!HELLO!I'm ISmileLi!HELLO!HELLO!I'm ISmileLi!";std::cout << "-------------------打印原来字符串的值------------------" << std::endl;std::cout << "tmpStrFind:" << tmpStrFind << std::endl;boost::iterator_range<std::string::iterator> rIter = boost::algorithm::find_first(tmpStrFind, "ISmileLi");std::cout << "查找第一个字符串出现的位置: " << rIter.begin() - tmpStrFind.begin() << std::endl;//迭代器计算位置rIter = boost::algorithm::find_last(tmpStrFind, "ISmileLi");std::cout << "查找最后一个字符串ISmileLi出现的位置: " << rIter.begin() - tmpStrFind.begin() << std::endl;rIter = boost::algorithm::find_nth(tmpStrFind, "HELLO", 3);std::cout << "查找第3个字符串HELLO出现的位置: " << rIter.begin() - tmpStrFind.begin() << std::endl;rIter = boost::algorithm::find_head(tmpStrFind, 3);std::cout << "查找开头3个字符串出现的位置: " << rIter.begin() - tmpStrFind.begin() << std::endl;std::cout << "rIter:" << rIter << std::endl;rIter = boost::algorithm::find_tail(tmpStrFind, 3);std::cout << "查找结尾3个字符串出现的位置: " << rIter.begin() - tmpStrFind.begin() << std::endl;std::cout << "rIter:" << rIter << std::endl;std::cout << "Hello World!\n";getchar();
}

6.字符串修剪

boost库提供了众多的字符串修剪函数,并且提供了很多版本供使用,例如以_copy、_if、_copy_if结尾的版本等,以满足使用者不同的需求。主要函数有trim_left、trim_right、trim这三种方式以及它们的变种版本。

#include <iostream>
#include <boost/algorithm/string.hpp>int main()
{std::cout << "-------------------boost库字符串修剪------------------" << std::endl;std::string tmpTrimSr = "  ...88HELLO!HELLO!I'm ISmileLi!HELLO!HELLO!I'm ISmileLi!666...  ";std::cout << "-------------------打印原来字符串的值------------------" << std::endl;std::cout << "tmpTrimSr:" << tmpTrimSr << std::endl;std::cout << "-------------------删除字符串空格------------------" << std::endl;std::string trimSpace = boost::algorithm::trim_copy(tmpTrimSr);std::cout << "不改变原字符串:" << trimSpace << std::endl;std::cout << "改变原字符串,删除左边:" << std::endl;boost::trim_left(tmpTrimSr);std::cout << tmpTrimSr << std::endl;std::cout << "改变原字符串,删除右边:" << std::endl;boost::trim_right(tmpTrimSr);std::cout << tmpTrimSr << std::endl;std::cout << "-------------------使用判别式删除字符串两端的空格、标点、数字------------------" << std::endl;std::cout << boost::trim_copy_if(tmpTrimSr, boost::is_space() || boost::is_punct() || boost::is_digit()) << std::endl;std::cout << "Hello World!\n";getchar();
}

7.字符串分割

boost库提供了一个分割函数split(),可以根据某种特定的字符或者策略把分割后的字符,保存到指定的容器中。

#include <iostream>
#include <vector>
#include <boost/algorithm/string.hpp>int main()
{std::cout << "-------------------boost库字符串分割------------------" << std::endl;std::string tmpStrFind = "HELLO!HELLO!I'm ISmileLi!HELLO!HELLO!I'm ISmileLi!";std::cout << "原字符串:" << tmpStrFind << std::endl;std::vector<std::string> splitVector;// 使用标点符号切割字符串boost::algorithm::split(splitVector, tmpStrFind, boost::algorithm::is_punct());std::cout << "-----------打印切割后的字符串----------" << std::endl;for (int i = 0; i < splitVector.size(); ++i){std::cout << splitVector.at(i) << std::endl;}// 常规用法std::string str = "Hello,World,How,Are,You";std::vector<std::string> result;boost::split(result, str, boost::is_any_of(","));std::cout << "Hello World!\n";getchar();
}

8.字符串合并

boost库提供了一个合并函数join(),它可以把存储在容器中的字符串通过指定的分隔符连接在一起。

#include <iostream>
#include <vector>
#include <boost/algorithm/string.hpp>int main()
{std::cout << "-------------------boost库字符串合并------------------" << std::endl;std::string tmpStrFind = "HELLO!HELLO!I'm ISmileLi!HELLO!HELLO!I'm ISmileLi!";std::cout << "原字符串:" << tmpStrFind << std::endl;std::vector<std::string> splitVector;// 使用标点符号切割字符串boost::algorithm::split(splitVector, tmpStrFind, boost::algorithm::is_punct());std::cout << "-----------打印切割后的字符串----------" << std::endl;for (int i = 0; i < splitVector.size(); ++i){std::cout << splitVector.at(i) << std::endl;}std::cout << "-----------使用合并函数join并打印合并后的字符串----------" << std::endl;std::cout << boost::algorithm::join(splitVector, "+") << std::endl;//lambda表达式std::string tempJoinIfStr = boost::algorithm::join_if(splitVector, "$$", [](std::string tmpStr) {return boost::algorithm::contains(tmpStr, "I");});std::cout << "tempJoinIfStr: " << tempJoinIfStr << std::endl;std::cout << "Hello World!\n";getchar();
}

9.总结

字符串的常用操作,软件工程师使用起来,还是非常方便快捷。

http://www.ds6.com.cn/news/49203.html

相关文章:

  • 商丘在线商城优化搜索点击次数的方法
  • 望野博物馆要门票吗上海seo优化bwyseo
  • 网站设置快捷方式到桌面百度关键词搜索排名查询
  • 去政府做网站技术会荒废吗推广普通话黑板报
  • 绵阳哪里可以做网站的地方搜狗站长管理平台
  • jsp做网站组件百度搜索引擎关键词
  • wordpress建站安全性舆情分析
  • 新乡手机网站建设电话seo关键词搜索和优化
  • 企业网站策划大纲模板域名服务器地址查询
  • 怎么申请网站空间域名网络平台营销
  • 工装公司经营范围苏州seo门户网
  • 企业营销网站建设高端网站建设公司
  • 高端网站设计公司如何做好互联网营销
  • 简约大气风格网站模板莆田seo
  • 长春怎么做网站海淀seo搜索引擎优化公司
  • 成都疾控最新通告营销网站seo推广
  • 星悦做任务网站是最近最火的关键词
  • 台州seo管理网站优化招商
  • 蓝奏云注册网站做网络推广
  • 网站推广有哪些方法长沙网站推广seo
  • 视频网站建设工具怎么建网站教程图解
  • 电商类网站怎么做推广刷粉网站推广
  • 可以用腾讯企业邮箱域名做网站网站seo优化方案设计
  • 做a的视频在线观看网站济南seo官网优化
  • 网站开发网上悼念网络推广营销公司
  • 绵阳市公司网站建设国外b站视频推广网站
  • 做博客网站用什么模板网页设计软件有哪些
  • 做原油的网站优化方案官网电子版
  • dedecms 做微网站网络营销是什么工作主要干啥
  • 找人做网站骗局百度推广收费多少