正则表达式学习

C# 下正则使用举例

string pattern="abc";

Regex reg = new Regex(pattern);

///源字符串

string s=“XXXXX”;

1.替换所有匹配字符串

reg.Replace(s,"替换后的字符串“);

2.搜索所有符合条件的字符串

MatchCollection mc=reg.Matches(s);

foreach(Match m in mc)

{

  //m.Value 代表响应字符串

  //m.Index 代表在s中的位置
{

正则速查表

https://www.cnblogs.com/lizhenlin/p/6654934.html

网页测试

https://www.runoob.com/try/try.php?filename=tryjsref_regexp4

学习

https://www.cnblogs.com/mingxiastory/p/5426913.html

https://www.cnblogs.com/lizhenlin/p/6654934.html

https://www.runoob.com/regexp/regexp-syntax.html

https://www.cnblogs.com/hehehehehe/p/6043710.html

https://www.cnblogs.com/caokai520/p/4511848.html

原文地址:https://www.cnblogs.com/noigel/p/10937044.html