C#:正则表达式

------------恢复内容开始------------

正则表达式所有语言都支持,主要有两个功能( 1 ). 检索:通过正则表达式,从字符串中得到我们想要的部分。

                                                                      ( 2 )匹配:给定字符串是否满足正则表达式的过滤逻辑,即正则表达式表述了一个字符串的书写规则

较常用Regex类下的静态方法IsMatch 

bool isMatch(string input,string pattern);

参数   input:需要检索的字符串

          pattern:需要匹配的正则表达式

返回值:如果正则表达式找到匹配项则返回ture,否则为false。

Match

Match Match(string input,string pattern)

返回值:为第一个匹配正则表达式的字符串

Matches

MatchCollection Matches(string input,string pattern)

返回值:为所有匹配正则表达式的字符串

Replaces函数

Replaces(string input,string pattern,string replacement)

返回值:为对字符串匹配部分进行替换后的新字符串

split拆分文本

string[] split(string input,string pattern)

------------恢复内容结束------------

原文地址:https://www.cnblogs.com/jiangxiaoming/p/12975529.html