几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   ObjectARX(VB.NET/C#) (http://www.dimcax.com/hust/forumdisplay.php?f=176)
-   -   【转帖】正则表达式(通配符比较) (http://www.dimcax.com/hust/showthread.php?t=9846)

yang686526 2009-04-21 03:38 PM

【转帖】正则表达式(通配符比较)
 
正则表达式(通配符比较)
www.dimcax.com
正则表达式(通配符比较)
一个月前一直没解决的问题,这次在家没事折腾了1个多星期,终于搞懂一点了做了个最简单的字符串使用通配符比较,上传了一个比较详细点的正则表达式教程 public static bool ismatch(this string source, string comparestring) { string temp = comparestring.replace("*", ".*"); comparestring = "^" + temp.replace("?", ".?") + "$"; regex rg = new regex(comparestring); return rg.ismatch(source); } 例: if (str.ismatch("*1*2")) str = "12" retrun true str = "aa1112" retun true str = "21" return false

下载次数:39
正则表达式非常的强大!!!
网络上用的很多!
书山有路勤为径,学海无涯苦作舟!


所有的时间均为北京时间。 现在的时间是 04:59 AM.