CSharp examples for Language Basics:Regex
find anything that isn't a digit
using System;//www . j av a 2 s. co m using System.Text.RegularExpressions; class MainClass { static void Main( string[] args ) { string testString = "abc, DEF, 123"; Console.WriteLine( "The test string is: \"{0}\"", testString ); // find anything that isn't a digit Console.WriteLine( "\nMatch any non-digit" ); DisplayMatches( testString, @"\D" ); } // display the matches to a regular expression private static void DisplayMatches( string input, string expression ) { foreach ( var regexMatch in Regex.Matches( input, expression ) ) Console.Write( "{0} ", regexMatch ); Console.WriteLine(); // move to the next line } }