1 Code
1 //[0-9]$ detects if the string ends with a number2 3 usingSystem;4 usingSystem.Collections.Generic;5 usingSystem.Linq;6 usingSystem.Net;7 usingSystem.Text;8 usingSystem.Text.RegularExpressions;9 usingSystem.Threading.Tasks;Ten One namespaceConsoleApplication7 A { - class Program - { the Static voidMain (string[] args) - { - - stringRegularExpression =@"[0-9]$"; +Regex RG =NewRegex (regularexpression); - + string[] contents = {@"@@@",@"1%^&34","a3bb33345","a321b3" }; A for(inti =0; I < contents. Length; i++) at { - if(RG. IsMatch (Contents[i])) - { -Console.WriteLine (contents[i]+"conforms to regular expression"); - } - Else in { -Console.WriteLine (Contents[i] +"non-conforming regular expression"); to + } - } the * Console.readkey (); $ }Panax Notoginseng } -}
2 effects
C # Regular Expression Basics [0-9]$ detects if a string ends with a number