the Regex class includes methods such as IsMatch, Match, matches, Replace, and Split . If you use the ^ and $ enclosing tags, it indicates that the entire string (not just the substring) must match the regular expression.
The 1.Match method matches the string .
string input = "test@sina.com"; Input string to match
String Patten = @ "[a-za-z]+@[a-za-z]+/.com$"; Regular expressions
Regex r = new Regex (patten); Declaring a Regex object
Match m = r.match (input); Match using the Match method
if (m.success)//loops output all matching substrings
{
return true;
}
Else
{
return false;
}
Regular Expression Symbol
/b matches a word boundary, refers to the position between the word and the space
/b matches non word boundaries
/d matches a numeric character, equivalent to [0-9]
/d matches a non-numeric character, equivalent to [^0-9]
/F matches a page feed character
/n matches a line feed
/R matches a return character
/s matches any white space characters, including spaces, tabs, page breaks, and so on
+ Match one or more of the previous child expressions
Note When using the transfer character "/", you need to precede the string with the "@" symbol for example:
String mystr= "ddd AAA ddd SS";
Regex r = new Regex (@ "/s+", regexoptions.singleline);
String outname = R.replace (MyStr, ",");
Outname will output: DDDAAADDDSS;