C# REGEX: NON-Alphanumeric Matching and Replacing (Reemplazo y búsqueda de caracteres no alfanuméricos)

using System; using System.Text; using System.Text.RegularExpressions; //Kevin Rodríguez - Costa Rica - 2015 namespace SnippetNameSpace { public static class SnippetClass { //SPANISH: // Este método obtiene los caracteres no alfanuméricos // y los reemplaza por nada, es decir: los elimina. //ENGLISH: // This method gets all the non alphanumeric characters // and replaces them with nothing, (Deletes them). public static String ReplaceNonAlphaNumeric(String Input) { return Regex.Replace(Input, @"\W", ""); } //SPANISH: // Este método retorna verdadero cuando encuentra // una ocurrencia con la expresión regular dada. //ENGLISH: // This method returns true when it finds a match // with the given Regex. public static Boolean IsNotAlphaNumeric(String Input) { return Regex.IsMatch(Input, @"\W"); } } }
This snippet does match every non alpha numerical character.

Este snippet encuentra cada caracter no alfanumérico.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.