C#正则表达式replace用法
Regex构造函数
Regex(string pattern)
Regex(string pattern,RegexOptions options)
参数说明
pattern:要匹配的正则表达式模式
options:指定是否要编译,忽略大小写等等
Regex.Replace方法
-C#
Regex.Replace(string input,string replacement)
Regex.Replace(string input,string replacement,int count)
Regex.Replace(string input,string replacement,int count,int startat)
Regex.Replace(string input,MatchEvaluator evaluator)
Regex.Replace(string input,MatchEvaluator evaluator,int count)
Regex.Replace(string input,MatchEvaluator evaluator,int count,int startat)
参数说明
input:要修改的字符串
replacement:替换字符串
count:进行替换的最大次数
startat:输入字符串开始搜索的位置
evaluator:在每一步计算替换的MatchEvaluator。就是一个函数代理,参数为Match类型,匹配的数据。
-C#
asp.net--C#字符串只执行一次替换的示例代码
string s = "aaa";
Regex r = new Regex("a");
s=r.Replace(s,"b",1);
Response.Write(s);//输出baa
最新文章
- embedding mono实战笔录(一)
- myeclipse+tomcat 工程名改名的问题 ——————完美解决方案
- GO语言练习:网络编程 ICMP 示例
- 网页二维码推广App的实现
- JAVA基础知识之练习题——集合
- c++builder6.0 mdi窗体+自定义子窗体
- delphi 自动滚动到最底端scroll
- 进程,线程(thread)
- eclipse安装Hadoop1.1.2版本开发插件
- TFboy养成记 CNN
- CTF---Web入门第三题 这个看起来有点简单!
- Curl是什么,原文地址:http://www.phpchina.com/portal.php?mod=view&;aid=40161
- 关于前端本地压缩图片,兼容IOS/Android/PC且自动按需加载文件之lrz.bundle.js
- CSS3 移动端 1PX 线变成0.5PX
- Android网页打开指定App
- 背水一战 Windows 10 (112) - 通知(Badge): application 的 badge 通知, secondary 的 badge 通知, 轮询服务端以更新 badge 通知
- HashMap代码解析
- windows服务安装 System.IO.FileLoadException
- python学习笔记(五)- 文件操作
- 第34 memcached缓存
热门文章
- JZOJ 5462. 【NOIP2017提高A组冲刺11.8】好文章
- Bubblesort冒泡算法
- 从0到n-1中随机等概率输出m个不同的数
- DFS:Tempter of the Bone (规定时间达到规定地点)
- sql中比较大小
- SpringCloud 微服务一:spring boot 基础项目搭建
- loj2052 「HNOI2016」矿区
- leetcode 【 Pascal's Triangle II 】python 实现
- 使用 Item,ItemManager 在 XNA 中创建物品和道具(十六)
- 04 JVM是如何执行方法调用的(下)