//下面是一个检查一个字符串中是否有'.'的函数,该函数将找到的'.'转化为'_'。
inline void checkName(string& name)
{
std::string::size_type startpos = ;
while (startpos!= std::string::npos)
{
startpos = name.find('.'); //找到'.'的位置
if( startpos != std::string::npos ) //std::string::npos表示没有找到该字符
{
name.replace(startpos,,"_"); //实施替换,注意后面一定要用""引起来,表示字符串
}
}
}

C++ string.replace的使用的更多相关文章

  1. Java String.replace()方法

    Java String.replace()方法用法实例教程, 返回一个新的字符串,用newChar替换此字符串中出现的所有oldChar 声明 以下是java.lang.String.replace( ...

  2. .net 基础错误-string.replace 方法

    1.string string.Replace(string oldValue,string newValue) 返回一个新的字符串,其中当前示例中出现的所有指定字符串都替换另一个指定字符串 错误:总 ...

  3. Python string replace 方法

    Python string replace   方法 方法1: >>> a='...fuck...the....world............' >>> b=a ...

  4. String.replace与String.format

    字符串的替换函数replace平常使用的频率非常高,format函数通常用来填补占位符.下面简单总结一下这两个函数的用法. 一.String.replace的两种用法 replace的用法如:repl ...

  5. [转]String.Replace 和 String.ReplaceAll 的区别

    JAVA 中的 replace replaceAll 问题: 测试code System.out.println("1234567890abcdef -----> "+&qu ...

  6. JAVA中string.replace()和string.replaceAll()的区别及用法

    乍一看,字面上理解好像replace只替换第一个出现的字符(受javascript的影响),replaceall替换所有的字符,其实大不然,只是替换的用途不一样.    public String r ...

  7. python 字符串替换功能 string.replace()可以用正则表达式,更优雅

    说起来不怕人笑话,我今天才发现,python 中的字符串替换操作,也就是 string.replace() 是可以用正则表达式的. 之前,我的代码写法如下,粗笨: 自从发现了正则表达式也生效后,代码变 ...

  8. [Algo] 649. String Replace (basic)

    Given an original string input, and two strings S and T, replace all occurrences of S in input with ...

  9. [Javascript] How to use JavaScript's String.replace

    In JavaScript, you can change the content of a string using the replace method. This method signatur ...

  10. string::replace

    #include <string> #include <cctype> #include <algorithm> #include <iostream> ...

随机推荐

  1. 001-notepad++下载安装、添加右键

    一.下载 1.1.下载地址:https://notepad-plus-plus.org/ 一般下载 /1.2 1.2.解压至指定路径下即可 1.3.注册表添加鼠标右键 添加鼠标右键, 保存成reg执行 ...

  2. Openstack_SQLAlchemy 修改数据库的表结构

    目录 目录 前言 更改数据库的方法 为数据库添加一张或多张新表 删除一张或多张表 为旧表添加一个字段 为旧表更新一个字段 为旧表初始化一条新的记录 最后 前言 SQLAlchemy 的使用方法和相关基 ...

  3. jvm 更多链接

    http://www.cnblogs.com/dingyingsi/p/3760447.html    :  讲解 jvm https://blog.csdn.net/Luomingkui1109/a ...

  4. DbWrench001--简介

    DbWrench--简介 mac下载地址:http://www.dbwrench.com/ DbWrench 工具等价于powerdesigner 均为数据库原型设计工具 DbWrench 详细介绍 ...

  5. ruby基本语法(2)

    关于数组 Ruby数组中的数据类型可以不相同并且长度也是可变的.(好聪明啊感觉用的久了就会变笨了,除非你本来就是老手)比如下面的例子 Myarray=[1,2,“ruby”] Ruby也支持那种-1的 ...

  6. out.write()和out.print()区别,jsp注释区别

    out.write()和out.print()结果一样,都是输出内容 前者输出html内容 后者输出变量 5 JSP注释 我们现在已经知道JSP是需要先编译成.java,再编译成.class的.其中& ...

  7. Pikachu漏洞练习平台实验——文件包含(File Inclusion)(六)

    1.概述 1.1简介 在 Web 后台开发中,程序员往往为了提高效率以及让代码看起来更加简洁,会使用 “包含” 函数功能.比如把一系列功能函数都写进 function.php 中,之后当某个文件需要调 ...

  8. [HDU 5293]Tree chain problem(树形dp+树链剖分)

    [HDU 5293]Tree chain problem(树形dp+树链剖分) 题面 在一棵树中,给出若干条链和链的权值,求选取不相交的链使得权值和最大. 分析 考虑树形dp,dp[x]表示以x为子树 ...

  9. spring(三):spring中BeanPostProcessor的使用

    spring中实现BeanPostProcessor的后置处理器 ApplicationContextAwareProcessor 进入该实现类内部 可以看到:该类帮我们组建IOC容器,判断我们的be ...

  10. tornado ioloop current和instance的一些区别

    import tornado.ioloop # 此时_current没有instance print dir(tornado.ioloop.IOLoop._current) # 通过instance ...