/  3
 
EXPRESIONES REGULARESNAMESPACE : System.Text.RegularExpressionsHow to: VALIDAR UN TEXTO CON UNA EXPRESION REGULAR System.Text.RegularExpressions.Regex.IsMatch(Expresion Regular, Cadena);Caracteres Especiales
^Comienzo de Cadena\dSolo digitos\sSolo espacios en blanco, tabs\wSolo cadenas{5}Longitud 5$Fin de Cadena
How to: SETEAR OPCIONES PARA BUSQUEDA DE EXPRESIONES REGULARESRegexOptions
NoneIgnoreCaseMultilineExplicitCaptureCompiledSinglelineIgnorePattern-WhitespaceRightToLeft
Regex.IsMatch(s, "^def$", RegexOptions.Multiline)match.Success :
Flag que indica si se encontro una coincidenciao no.
/*Groups
collection on Match objects
 starts at 1.
*/How to : OBTENER LAS COINCIDENCIAS DE UNA EXPRESION REGULAR EN UNTEXTO
 // C#string input = "Company Name: Contoso, Inc.";Match m = Regex.Match(input, @"Company Name:
(.*$)"
);Console.WriteLine(
m.Groups[1]
);
How to : REEMPLAZAR SUBCADENAS USANDO EXPRESIONES REGULARES
String MDYToDMY(String input){return
Regex.Replace
(input,"\\b(?<month>\\d{1,2})/(?<day>\\d{1,2})/(?<year>\\d{2,4})\\b","${day}-${month}-${year}");}
ENCODING/DECODING
 
NAMESPACE :
System.Text.Encoding.GetEncodingHOW TO : OBTENER LOS BYTES DE UNA CADENA CON UNA CODIFICACIONESPECIFICA.Encoding.GetBytesHow to : OBTENER LAS CODIFICACIONES DISPONIBLES
EncodingInfo[] ei =
Encoding.GetEncodings
();
How to : ESPECIFICAR CODIFICACION CUANDO SE LEE O ESCRIBE UN ARCHIVO
 // ESCRITURAStreamWriter swUtf7 = new StreamWriter("utf7.txt", false,
Encoding.UTF7)
;swUtf7.WriteLine("Hello, World!");swUtf7.Close(); // LECTURAStreamReader sr = new StreamReader(fn,
Encoding.UTF7
);Console.WriteLine(sr.ReadToEnd());sr.Close();
SOLUCION EJERCICIOS
 /*
Practice 1
Write a console application that reads your C:\boot.ini file and displays just the timeout.
Practice 4
Write a console application that reads the %windir%\Windows-Update.log file, changes the date format to mm-dd-yy, and writes the outputto asecond file.
Practice 5
Write a console application with a method that reads the%windir%\WindowsUpdate.log file and writes the output to a second file usingan encoding type provided in a parameter. Compare the file sizes of eachencodingtype.*/ // 1. /*StreamReader streamReader = newStreamReader(@"C:\Users\Carlos\Documents\Visual Studio2005\Projects\MCTS_Testing\MCTS_Testing\Capitulo3\ArchivoBusqueda.txt");String archivoContenido = streamReader.ReadToEnd();Match match = Regex.Match(archivoContenido, @"%([A-Za-z0-9\-]+)%"); //([A-Za-z0-9\-]+) : Alfanumericoif (match.Success){

Share & Embed

More from this user

Add a Comment

Characters: ...