使用Regex 還有 MatchCollection, 引用命名空間using System.Text.RegularExpressions;
方法如下
1 |
MatchCollection mc; |
2 |
Regex r = new Regex( "," ); //搜尋字元是逗號 |
3 |
mc = r.Matches( "alskjd,989,pppp.00" ); //隨便輸入一組字串,內有兩個逗號 |
4 |
Response.Write(mc.Count.ToString()); |
參考網站:http://www.dotblogs.com.tw/sun222/archive/2011/03/22/22013.aspx
全站熱搜
留言列表