代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
Asp.Net
】
C#判断各种字符串(如手机号)
作者:
Dezai.CN
/ 发布于
2011/4/26
/
765
<div> <pre><div><span style="color: rgb(0,128,128)"> 1</span> <span style="color: rgb(0,0,255)">using</span><span style="color: rgb(0,0,0)"> System;</span><span style="color: rgb(0,128,128)"> 2</span> <span style="color: rgb(0,0,255)">using</span><span style="color: rgb(0,0,0)"> System.Text.RegularExpressions;</span><span style="color: rgb(0,128,128)"> 3</span> <span style="color: rgb(0,0,255)">namespace</span><span style="color: rgb(0,0,0)"> MetarCommonSupport</span><span style="color: rgb(0,128,128)"> 4</span> <span style="color: rgb(0,0,0)">{</span><span style="color: rgb(0,128,128)"> 5</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 6</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 通过Framwork类库中的Regex类实现了一些特殊功能数据检查</span><span style="color: rgb(0,128,128)"> 7</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(128,128,128)"></span><span style="color: rgb(0,128,128)"> 8</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">class</span><span style="color: rgb(0,0,0)"> MetarnetRegex</span><span style="color: rgb(0,128,128)"> 9</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)"> 10</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)"> 11</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">private</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> MetarnetRegex instance </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">null</span><span style="color: rgb(0,0,0)">;</span><span style="color: rgb(0,128,128)"> 12</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> MetarnetRegex GetInstance()</span><span style="color: rgb(0,128,128)"> 13</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)"> 14</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (MetarnetRegex.instance </span><span style="color: rgb(0,0,0)">==</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">null</span><span style="color: rgb(0,0,0)">)</span><span style="color: rgb(0,128,128)"> 15</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)"> 16</span> <span style="color: rgb(0,0,0)"> MetarnetRegex.instance </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> MetarnetRegex();</span><span style="color: rgb(0,128,128)"> 17</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)"> 18</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> MetarnetRegex.instance;</span><span style="color: rgb(0,128,128)"> 19</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)"> 20</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">private</span><span style="color: rgb(0,0,0)"> MetarnetRegex()</span><span style="color: rgb(0,128,128)"> 21</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)"> 22</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)"> 23</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 24</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 判断输入的字符串只包含汉字</span><span style="color: rgb(0,128,128)"> 25</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 26</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 27</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"></span><span style="color: rgb(0,128,128)"> 28</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsChineseCh(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> input)</span><span style="color: rgb(0,128,128)"> 29</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)"> 30</span> <span style="color: rgb(0,0,0)"> Regex regex </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">^[\u4e00-\u9fa5]+$</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">);</span><span style="color: rgb(0,128,128)"> 31</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> regex.IsMatch(input);</span><span style="color: rgb(0,128,128)"> 32</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)"> 33</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 34</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 匹配3位或4位区号的电话号码,其中区号可以用小括号括起来,</span><span style="color: rgb(0,128,128)"> 35</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 也可以不用,区号与本地号间可以用连字号或空格间隔,</span><span style="color: rgb(0,128,128)"> 36</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 也可以没有间隔</span><span style="color: rgb(0,128,128)"> 37</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> \(0\d{2}\)[- ]?\d{8}|0\d{2}[- ]?\d{8}|\(0\d{3}\)[- ]?\d{7}|0\d{3}[- ]?\d{7}</span><span style="color: rgb(0,128,128)"> 38</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 39</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 40</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"></span><span style="color: rgb(0,128,128)"> 41</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsPhone(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> input)</span><span style="color: rgb(0,128,128)"> 42</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)"> 43</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> pattern </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">^\\(0\\d{2}\\)[- ]?\\d{8}$|^0\\d{2}[- ]?\\d{8}$|^\\(0\\d{3}\\)[- ]?\\d{7}$|^0\\d{3}[- ]?\\d{7}$</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">;</span><span style="color: rgb(0,128,128)"> 44</span> <span style="color: rgb(0,0,0)"> Regex regex </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(pattern);</span><span style="color: rgb(0,128,128)"> 45</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> regex.IsMatch(input);</span><span style="color: rgb(0,128,128)"> 46</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)"> 47</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 48</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 判断输入的字符串是否是一个合法的手机号</span><span style="color: rgb(0,128,128)"> 49</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 50</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 51</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"></span><span style="color: rgb(0,128,128)"> 52</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsMobilePhone(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> input)</span><span style="color: rgb(0,128,128)"> 53</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)"> 54</span> <span style="color: rgb(0,0,0)"> Regex regex </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">^13\\d{9}$</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">);</span><span style="color: rgb(0,128,128)"> 55</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> regex.IsMatch(input);</span><span style="color: rgb(0,128,128)"> 56</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)"> 57</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)"> 58</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)"> 59</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)"> 60</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 61</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 判断输入的字符串只包含数字</span><span style="color: rgb(0,128,128)"> 62</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 可以匹配整数和浮点数</span><span style="color: rgb(0,128,128)"> 63</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> ^-?\d+$|^(-?\d+)(\.\d+)?$</span><span style="color: rgb(0,128,128)"> 64</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 65</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 66</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"></span><span style="color: rgb(0,128,128)"> 67</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsNumber(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> input)</span><span style="color: rgb(0,128,128)"> 68</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)"> 69</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> pattern </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">^-?\\d+$|^(-?\\d+)(\\.\\d+)?$</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">;</span><span style="color: rgb(0,128,128)"> 70</span> <span style="color: rgb(0,0,0)"> Regex regex </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(pattern);</span><span style="color: rgb(0,128,128)"> 71</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> regex.IsMatch(input);</span><span style="color: rgb(0,128,128)"> 72</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)"> 73</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 74</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 匹配非负整数</span><span style="color: rgb(0,128,128)"> 75</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 76</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 77</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 78</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"></span><span style="color: rgb(0,128,128)"> 79</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsNotNagtive(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> input)</span><span style="color: rgb(0,128,128)"> 80</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)"> 81</span> <span style="color: rgb(0,0,0)"> Regex regex </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(</span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">^\d+$</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">);</span><span style="color: rgb(0,128,128)"> 82</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> regex.IsMatch(input);</span><span style="color: rgb(0,128,128)"> 83</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)"> 84</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 85</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 匹配正整数</span><span style="color: rgb(0,128,128)"> 86</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 87</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 88</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"></span><span style="color: rgb(0,128,128)"> 89</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsUint(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> input)</span><span style="color: rgb(0,128,128)"> 90</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)"> 91</span> <span style="color: rgb(0,0,0)"> Regex regex </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">^[0-9]*[1-9][0-9]*$</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">);</span><span style="color: rgb(0,128,128)"> 92</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> regex.IsMatch(input);</span><span style="color: rgb(0,128,128)"> 93</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)"> 94</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 95</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 判断输入的字符串字包含英文字母</span><span style="color: rgb(0,128,128)"> 96</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 97</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)"> 98</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"></span><span style="color: rgb(0,128,128)"> 99</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsEnglisCh(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> input)</span><span style="color: rgb(0,128,128)">100</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">101</span> <span style="color: rgb(0,0,0)"> Regex regex </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">^[A-Za-z]+$</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">);</span><span style="color: rgb(0,128,128)">102</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> regex.IsMatch(input);</span><span style="color: rgb(0,128,128)">103</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">104</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">105</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">106</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">107</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 判断输入的字符串是否是一个合法的Email地址</span><span style="color: rgb(0,128,128)">108</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">109</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">110</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"></span><span style="color: rgb(0,128,128)">111</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsEmail(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> input)</span><span style="color: rgb(0,128,128)">112</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">113</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> pattern </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">;</span><span style="color: rgb(0,128,128)">114</span> <span style="color: rgb(0,0,0)"> Regex regex </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(pattern);</span><span style="color: rgb(0,128,128)">115</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> regex.IsMatch(input);</span><span style="color: rgb(0,128,128)">116</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">117</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">118</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">119</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">120</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 判断输入的字符串是否只包含数字和英文字母</span><span style="color: rgb(0,128,128)">121</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">122</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">123</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"></span><span style="color: rgb(0,128,128)">124</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsNumAndEnCh(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> input)</span><span style="color: rgb(0,128,128)">125</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">126</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> pattern </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">^[A-Za-z0-9]+$</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">;</span><span style="color: rgb(0,128,128)">127</span> <span style="color: rgb(0,0,0)"> Regex regex </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(pattern);</span><span style="color: rgb(0,128,128)">128</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> regex.IsMatch(input);</span><span style="color: rgb(0,128,128)">129</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">130</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">131</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">132</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">133</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 判断输入的字符串是否是一个超链接</span><span style="color: rgb(0,128,128)">134</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">135</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">136</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"></span><span style="color: rgb(0,128,128)">137</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsURL(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> input)</span><span style="color: rgb(0,128,128)">138</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">139</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">//</span><span style="color: rgb(0,128,0)">string pattern = @"http:</span><span style="color: rgb(0,128,0)">//</span><span style="color: rgb(0,128,0)">([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?";</span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">140</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> pattern </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">^[a-zA-Z]+://(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">;</span><span style="color: rgb(0,128,128)">141</span> <span style="color: rgb(0,0,0)"> Regex regex </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(pattern);</span><span style="color: rgb(0,128,128)">142</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> regex.IsMatch(input);</span><span style="color: rgb(0,128,128)">143</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">144</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">145</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">146</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">147</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 判断输入的字符串是否是表示一个IP地址</span><span style="color: rgb(0,128,128)">148</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">149</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></span><span style="color: rgb(0,128,0)">被比较的字符串</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">150</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></span><span style="color: rgb(0,128,0)">是IP地址则为True</span><span style="color: rgb(128,128,128)"></returns></span><span style="color: rgb(128,128,128)"></span><span style="color: rgb(0,128,128)">151</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsIPv4(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> input)</span><span style="color: rgb(0,128,128)">152</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">153</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">154</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)">[] IPs </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> input.Split(</span><span style="color: rgb(128,0,0)">'</span><span style="color: rgb(128,0,0)">.</span><span style="color: rgb(128,0,0)">'</span><span style="color: rgb(0,0,0)">);</span><span style="color: rgb(0,128,128)">155</span> <span style="color: rgb(0,0,0)"> Regex regex </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(</span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">^\d+$</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">);</span><span style="color: rgb(0,128,128)">156</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">for</span><span style="color: rgb(0,0,0)"> (</span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> i </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,128)">0</span><span style="color: rgb(0,0,0)">; i </span><span style="color: rgb(0,0,0)"><</span><span style="color: rgb(0,0,0)"> IPs.Length; i</span><span style="color: rgb(0,0,0)">++</span><span style="color: rgb(0,0,0)">)</span><span style="color: rgb(0,128,128)">157</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">158</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (</span><span style="color: rgb(0,0,0)">!</span><span style="color: rgb(0,0,0)">regex.IsMatch(IPs[i]))</span><span style="color: rgb(0,128,128)">159</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">160</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">false</span><span style="color: rgb(0,0,0)">;</span><span style="color: rgb(0,128,128)">161</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">162</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (Convert.ToUInt16(IPs[i]) </span><span style="color: rgb(0,0,0)">></span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,128)">255</span><span style="color: rgb(0,0,0)">)</span><span style="color: rgb(0,128,128)">163</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">164</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">false</span><span style="color: rgb(0,0,0)">;</span><span style="color: rgb(0,128,128)">165</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">166</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">167</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">true</span><span style="color: rgb(0,0,0)">;</span><span style="color: rgb(0,128,128)">168</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">169</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">170</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">171</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">172</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 计算字符串的字符长度,一个汉字字符将被计算为两个字符</span><span style="color: rgb(0,128,128)">173</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">174</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></span><span style="color: rgb(0,128,0)">需要计算的字符串</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">175</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></span><span style="color: rgb(0,128,0)">返回字符串的长度</span><span style="color: rgb(128,128,128)"></returns></span><span style="color: rgb(128,128,128)"></span><span style="color: rgb(0,128,128)">176</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> GetCount(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> input)</span><span style="color: rgb(0,128,128)">177</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">178</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> Regex.Replace(input, </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">[\u4e00-\u9fa5/g]</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">aa</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">).Length;</span><span style="color: rgb(0,128,128)">179</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">180</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">181</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">182</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 调用Regex中IsMatch函数实现一般的正则表达式匹配</span><span style="color: rgb(0,128,128)">183</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">184</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="pattern"></span><span style="color: rgb(0,128,0)">要匹配的正则表达式模式。</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">185</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></span><span style="color: rgb(0,128,0)">要搜索匹配项的字符串</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">186</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></span><span style="color: rgb(0,128,0)">如果正则表达式找到匹配项,则为 true;否则,为 false。</span><span style="color: rgb(128,128,128)"></returns></span><span style="color: rgb(128,128,128)"></span><span style="color: rgb(0,128,128)">187</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsMatch(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> pattern, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> input)</span><span style="color: rgb(0,128,128)">188</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">189</span> <span style="color: rgb(0,0,0)"> Regex regex </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(pattern);</span><span style="color: rgb(0,128,128)">190</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> regex.IsMatch(input);</span><span style="color: rgb(0,128,128)">191</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">192</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">193</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">194</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 从输入字符串中的第一个字符开始,用替换字符串替换指定的正则表达式模式的所有匹配项。</span><span style="color: rgb(0,128,128)">195</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">196</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="pattern"></span><span style="color: rgb(0,128,0)">模式字符串</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">197</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></span><span style="color: rgb(0,128,0)">输入字符串</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">198</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="replacement"></span><span style="color: rgb(0,128,0)">用于替换的字符串</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">199</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></span><span style="color: rgb(0,128,0)">返回被替换后的结果</span><span style="color: rgb(128,128,128)"></returns></span><span style="color: rgb(128,128,128)"></span><span style="color: rgb(0,128,128)">200</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> Replace(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> pattern, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> input, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> replacement)</span><span style="color: rgb(0,128,128)">201</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">202</span> <span style="color: rgb(0,0,0)"> Regex regex </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(pattern);</span><span style="color: rgb(0,128,128)">203</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> regex.Replace(input, replacement);</span><span style="color: rgb(0,128,128)">204</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">205</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">206</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">207</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 在由正则表达式模式定义的位置拆分输入字符串。</span><span style="color: rgb(0,128,128)">208</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">209</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="pattern"></span><span style="color: rgb(0,128,0)">模式字符串</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">210</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></span><span style="color: rgb(0,128,0)">输入字符串</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">211</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"></span><span style="color: rgb(0,128,128)">212</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)">[] Split(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> pattern, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> input)</span><span style="color: rgb(0,128,128)">213</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">214</span> <span style="color: rgb(0,0,0)"> Regex regex </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(pattern);</span><span style="color: rgb(0,128,128)">215</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> regex.Split(input);</span><span style="color: rgb(0,128,128)">216</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">217</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">218</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 判断输入的字符串是否是合法的IPV6 地址</span><span style="color: rgb(0,128,128)">219</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">220</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">221</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></returns></span><span style="color: rgb(128,128,128)"></span><span style="color: rgb(0,128,128)">222</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsIPV6(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> input)</span><span style="color: rgb(0,128,128)">223</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">224</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> pattern </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0)">""</span><span style="color: rgb(0,0,0)">;</span><span style="color: rgb(0,128,128)">225</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> temp </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> input;</span><span style="color: rgb(0,128,128)">226</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)">[] strs </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> temp.Split(</span><span style="color: rgb(128,0,0)">'</span><span style="color: rgb(128,0,0)">:</span><span style="color: rgb(128,0,0)">'</span><span style="color: rgb(0,0,0)">);</span><span style="color: rgb(0,128,128)">227</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (strs.Length </span><span style="color: rgb(0,0,0)">></span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,128)">8</span><span style="color: rgb(0,0,0)">)</span><span style="color: rgb(0,128,128)">228</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">229</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">false</span><span style="color: rgb(0,0,0)">;</span><span style="color: rgb(0,128,128)">230</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">231</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> count </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> MetarnetRegex.GetStringCount(input, </span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(128,0,0)">::</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">);</span><span style="color: rgb(0,128,128)">232</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (count </span><span style="color: rgb(0,0,0)">></span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,128)">1</span><span style="color: rgb(0,0,0)">)</span><span style="color: rgb(0,128,128)">233</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">234</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">false</span><span style="color: rgb(0,0,0)">;</span><span style="color: rgb(0,128,128)">235</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">236</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">else</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (count </span><span style="color: rgb(0,0,0)">==</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,128)">0</span><span style="color: rgb(0,0,0)">)</span><span style="color: rgb(0,128,128)">237</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">238</span> <span style="color: rgb(0,0,0)"> pattern </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">^([\da-f]{1,4}:){7}[\da-f]{1,4}$</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">;</span><span style="color: rgb(0,128,128)">239</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">240</span> <span style="color: rgb(0,0,0)"> Regex regex </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(pattern);</span><span style="color: rgb(0,128,128)">241</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> regex.IsMatch(input);</span><span style="color: rgb(0,128,128)">242</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">243</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">else</span><span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">244</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">245</span> <span style="color: rgb(0,0,0)"> pattern </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,0)">@"</span><span style="color: rgb(128,0,0)">^([\da-f]{1,4}:){0,5}::([\da-f]{1,4}:){0,5}[\da-f]{1,4}$</span><span style="color: rgb(128,0,0)">"</span><span style="color: rgb(0,0,0)">;</span><span style="color: rgb(0,128,128)">246</span> <span style="color: rgb(0,0,0)"> Regex regex1 </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Regex(pattern);</span><span style="color: rgb(0,128,128)">247</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> regex1.IsMatch(input);</span><span style="color: rgb(0,128,128)">248</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">249</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">250</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">251</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,128,0)">/*</span><span style="color: rgb(0,128,0)"> *******************************************************************</span><span style="color: rgb(0,128,128)">252</span> <span style="color: rgb(0,128,0)"> * 1、通过“:”来分割字符串看得到的字符串数组长度是否小于等于8</span><span style="color: rgb(0,128,128)">253</span> <span style="color: rgb(0,128,0)"> * 2、判断输入的IPV6字符串中是否有“::”。</span><span style="color: rgb(0,128,128)">254</span> <span style="color: rgb(0,128,0)"> * 3、如果没有“::”采用 ^([\da-f]{1,4}:){7}[\da-f]{1,4}$ 来判断</span><span style="color: rgb(0,128,128)">255</span> <span style="color: rgb(0,128,0)"> * 4、如果有“::” ,判断"::"是否止出现一次</span><span style="color: rgb(0,128,128)">256</span> <span style="color: rgb(0,128,0)"> * 5、如果出现一次以上 返回false</span><span style="color: rgb(0,128,128)">257</span> <span style="color: rgb(0,128,0)"> * 6、^([\da-f]{1,4}:){0,5}::([\da-f]{1,4}:){0,5}[\da-f]{1,4}$</span><span style="color: rgb(0,128,128)">258</span> <span style="color: rgb(0,128,0)"> * *****************************************************************</span><span style="color: rgb(0,128,0)">*/</span><span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">259</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">260</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 判断字符串compare 在 input字符串中出现的次数</span><span style="color: rgb(0,128,128)">261</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">262</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></span><span style="color: rgb(0,128,0)">源字符串</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">263</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="compare"></span><span style="color: rgb(0,128,0)">用于比较的字符串</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"></span><span style="color: rgb(0,128,128)">264</span> <span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><returns></span><span style="color: rgb(0,128,0)">字符串compare 在 input字符串中出现的次数</span><span style="color: rgb(128,128,128)"></returns></span><span style="color: rgb(128,128,128)"></span><span style="color: rgb(0,128,128)">265</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">private</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> GetStringCount(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> input, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> compare)</span><span style="color: rgb(0,128,128)">266</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">267</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> index </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> input.IndexOf(compare);</span><span style="color: rgb(0,128,128)">268</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (index </span><span style="color: rgb(0,0,0)">!=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(128,0,128)">1</span><span style="color: rgb(0,0,0)">)</span><span style="color: rgb(0,128,128)">269</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">270</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,128)">1</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">+</span><span style="color: rgb(0,0,0)"> GetStringCount(input.Substring(index </span><span style="color: rgb(0,0,0)">+</span><span style="color: rgb(0,0,0)"> compare.Length), compare);</span><span style="color: rgb(0,128,128)">271</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">272</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">else</span><span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">273</span> <span style="color: rgb(0,0,0)"> {</span><span style="color: rgb(0,128,128)">274</span> <span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(128,0,128)">0</span><span style="color: rgb(0,0,0)">;</span><span style="color: rgb(0,128,128)">275</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">276</span> <span style="color: rgb(0,0,0)"></span><span style="color: rgb(0,128,128)">277</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">278</span> <span style="color: rgb(0,0,0)"> }</span><span style="color: rgb(0,128,128)">279</span> <span style="color: rgb(0,0,0)">}</span></div></pre> </div>
试试其它关键字
判断各种字符串
同语言下
.
gzip压缩
.
实现http多线程断点续传下载文件
.
实现多线程断点续传下载大文件
.
生成字符串的 CheckSum
.
根据 UserAgent 获取浏览器的类型和版本
.
根据 Agent 判断是否是智能手机
.
隐藏手机号中间四位为*方法
.
合并图片(二维码和其他图片合并)
.
ASP.NET CORE中判断是否移动端打开网页
.
ASP.NET(C#)实现页面计时(定时)自动跳转
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
Dezai.CN
贡献的其它代码
(
4037
)
.
多线程Socket服务器模块
.
生成随机密码
.
清除浮动样式
.
弹出窗口居中
.
抓取url的函数
.
使用base HTTP验证
.
div模拟iframe嵌入效果
.
通过header转向的方法
.
Session操作类
.
执行sqlite输入插入操作后获得自动编号的ID
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3