Application of the regular expression in .net - novice work notes

.net in the regular expression should be introduced System.Text.RegularExpressions namespace

In this space there Regex class, write regular expressions instantiate the class

Regex regex = new Regex ( "regular expressions");

if (regex.IsMatch ( "To verify that the character string")) {

  sucess!

}else{

  error!

}

Common regular expression:

Pure numbers: ^ [0-9] * $

Pure letters: ^ [az, AZ] * $

email: ^ [a-zA-Z0-9 _.-] + @ [a-zA-Z0-9 -] + \. [a-zA-Z0-9 .-] + $

ID: ^ \\ d {15} | \\ d {} 18 $

 

Reproduced in: https: //www.cnblogs.com/maomaoBlog/archive/2010/03/10/1682261.html

Guess you like

Origin blog.csdn.net/weixin_34321977/article/details/93273339