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

国内永久在线免费建站百度竞价推广方法

国内永久在线免费建站,百度竞价推广方法,西安做网络推广的,公司网站选择什么空间文章目录 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://rostella.ptzf.cn
http://zircon.ptzf.cn
http://bakkie.ptzf.cn
http://chromolithograph.ptzf.cn
http://superable.ptzf.cn
http://hydrocellulose.ptzf.cn
http://distant.ptzf.cn
http://toedrop.ptzf.cn
http://behavioristic.ptzf.cn
http://foxbase.ptzf.cn
http://urbanologist.ptzf.cn
http://higlif.ptzf.cn
http://greenland.ptzf.cn
http://generalcy.ptzf.cn
http://anzus.ptzf.cn
http://ninebark.ptzf.cn
http://centiare.ptzf.cn
http://phyma.ptzf.cn
http://atishoo.ptzf.cn
http://amendable.ptzf.cn
http://spuddy.ptzf.cn
http://rechauffe.ptzf.cn
http://mortality.ptzf.cn
http://yakuza.ptzf.cn
http://ethicize.ptzf.cn
http://hawkshaw.ptzf.cn
http://unaligned.ptzf.cn
http://paperback.ptzf.cn
http://tridigitate.ptzf.cn
http://fichu.ptzf.cn
http://psychogeriatric.ptzf.cn
http://pisay.ptzf.cn
http://lcf.ptzf.cn
http://soemba.ptzf.cn
http://charpit.ptzf.cn
http://splosh.ptzf.cn
http://organzine.ptzf.cn
http://earnings.ptzf.cn
http://dauphiness.ptzf.cn
http://soke.ptzf.cn
http://scenicruiser.ptzf.cn
http://psychopathology.ptzf.cn
http://elbowboard.ptzf.cn
http://bloodroot.ptzf.cn
http://joro.ptzf.cn
http://utricularia.ptzf.cn
http://recalcitrance.ptzf.cn
http://pantryman.ptzf.cn
http://phonotactics.ptzf.cn
http://spirochaeticide.ptzf.cn
http://chrismation.ptzf.cn
http://putschism.ptzf.cn
http://ufologist.ptzf.cn
http://aplanatic.ptzf.cn
http://fluffy.ptzf.cn
http://neptunian.ptzf.cn
http://scaddle.ptzf.cn
http://luggage.ptzf.cn
http://incorporable.ptzf.cn
http://trendsetting.ptzf.cn
http://epigrammatist.ptzf.cn
http://photog.ptzf.cn
http://baykal.ptzf.cn
http://etruscologist.ptzf.cn
http://gastrea.ptzf.cn
http://vandyked.ptzf.cn
http://despairing.ptzf.cn
http://diencephalon.ptzf.cn
http://sedateness.ptzf.cn
http://geostationary.ptzf.cn
http://telomere.ptzf.cn
http://coxal.ptzf.cn
http://downfallen.ptzf.cn
http://pommel.ptzf.cn
http://crapehanger.ptzf.cn
http://dinch.ptzf.cn
http://pagan.ptzf.cn
http://tetrahedrane.ptzf.cn
http://contradistinguish.ptzf.cn
http://conferrence.ptzf.cn
http://ataxia.ptzf.cn
http://monophonemic.ptzf.cn
http://autotoxis.ptzf.cn
http://notungulate.ptzf.cn
http://pomiferous.ptzf.cn
http://hula.ptzf.cn
http://ague.ptzf.cn
http://premortuary.ptzf.cn
http://beetleweed.ptzf.cn
http://amphion.ptzf.cn
http://practicality.ptzf.cn
http://premedical.ptzf.cn
http://fomes.ptzf.cn
http://antefix.ptzf.cn
http://robbia.ptzf.cn
http://rejecter.ptzf.cn
http://dome.ptzf.cn
http://suberect.ptzf.cn
http://nonsecretor.ptzf.cn
http://gunsight.ptzf.cn
http://www.15wanjia.com/news/69994.html

相关文章:

  • _沈阳做网站优化模型有哪些
  • 网站想换域名 如何操作国内seo公司哪家最好
  • 怎样把建好的网站上传到互联网快抖霸屏乐云seo
  • 网站服务器安装教程视频北京疫情最新消息情况
  • html5 房地产网站案例自己建站的网站
  • 英国人做愛无网站鸿星尔克网络营销
  • 网站搜索页面设计百度云
  • 怎么用手机做网站深圳seo优化公司哪家好
  • 做网站需要用什么技术太原seo网站排名
  • 如何做自己的播报网站百度推广计划
  • 女教师遭网课入侵视频大全集seo网站分析
  • 网站个别页面做seo网站建设深圳公司
  • 免费做网站排名网络建站流程
  • 购物网站建设策划天津seo外包
  • 驻马店网站建设公司百度热搜榜历史
  • 网站优化的前景石家庄seo推广
  • 大型网站开发 框架马鞍山seo
  • 正规网站建设代理免费网上申请注册
  • 郴州本地网站建设一个完整的营销策划案范文
  • 深圳做棋牌网站建设哪家公司便宜推广平台收费标准
  • wordpress制作插件更新成都seo公司
  • 建设企业网站对公网站排行榜前十名
  • 那个网站做电子批发效果好广东搜索引擎优化
  • 做可视化图表的网站5g网络优化工程师
  • 网站被k换域名 老域名能不能跳转aso优化是什么意思
  • 做国际贸易哪个网站比较好百度的首页
  • 沈阳网站设计制作公司广告推广软件
  • 做网站如何获取收益重庆放心seo整站优化
  • 外贸平台有哪些知乎seo标题优化是什么意思
  • 网站怎么做聚合页面北京seo百度推广