1 Code
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Net;5 usingSystem.Text;6 usingSystem.Text.RegularExpressions;7 usingSystem.Threading.Tasks;8 9 namespaceConsoleApplication7Ten { One class Program A { - Static voidMain (string[] args) - { the //detects whether a string exists with two contiguous digits - stringRegularExpression ="[0-9][0-9]"; -Regex RG =NewRegex (regularexpression); - + string[] contents = {" on","12a","A3","A33" }; - for(inti =0; I < contents. Length; i++) + { A if(RG. IsMatch (Contents[i])) at { -Console.WriteLine (contents[i]+"conforms to regular expression"); - } - Else - { -Console.WriteLine (Contents[i] +"non-conforming regular expression"); in - } to } + - Console.readkey (); the } * } $}
2 effects
C # Regular Expression Foundation [0-9][0-9] detects whether a string has two contiguous digits