Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Testing 12
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //string pattern = "(Mr\\.? |Mrs\\.? |Miss |Ms\\.? )"; //string[] names = { "Mr. Henry Hunt", "Ms. Sara Samuels", "Abraham Adams", "Ms. Nicole Norris" }; //foreach (string name in names) //Console.WriteLine(Regex.Replace(name, pattern, String.Empty)); string numero = "A203"; var Characters = @"/[`~!@#$%^&*()_|+\-=?;:',.<>\{\}\[\]\\\/]/gi"; //string cadena = Regex.Replace(numero, Characters, String.Empty); string cadena = numero.Replace(Characters, String.Empty).Trim(); //string pattern = @"^[0-1](\.[a-zA-Z])?$"; //string pattern = @"^[0-1]+$"; // Número Binario string pattern = @"^[0-9]+$"; // Número Decimales Regex Val = new Regex(pattern); if(Val.IsMatch(numero)) { Console.WriteLine("El Número: {0}",numero+" es Binario."); } else { Console.WriteLine("El Número no es Binario."); } // Conversiones Binarias int bin = 11111; int dec = 31; String hex = "1f"; int res = 0; String result = ""; // Convertir de Binario a Decimal res = Convert.ToInt32(bin.ToString(),2); Console.WriteLine(""); Console.WriteLine("El Número Decimal es: {0}",res.ToString()); // Convertir de Binario a Hexadecimal result = Convert.ToString(Convert.ToUInt32(bin.ToString(), 2), 16).ToUpper(); Console.WriteLine(""); Console.WriteLine("El Número Hexadecimal es: {0}",result); /* // Convertir de Decimal a Hexadecimal res = Convert.ToInt32(dec.ToString(),16); result = Convert.ToString(res, 16); Console.WriteLine(""); Console.WriteLine("El Número Hexadecimal es: {0}",result); */ // Convertir de Decimal a Binario int res1 = Convert.ToByte(dec.ToString(),16); Console.WriteLine(""); Console.WriteLine("El Número Binario es: {0}",res1.ToString()); // Convertir de Hexadecimal a Binario string pattern1 = @"^[0-9A-Fa-f]+$"; // Número Decimales Regex exp = new Regex(pattern1); if(exp.IsMatch(hex)) { result = Convert.ToString(Convert.ToInt32(hex,16), 2); Console.WriteLine(""); Console.WriteLine("El Número Binario es: {0}",result); } else { Console.WriteLine(""); Console.WriteLine("El Número no es Hexadecimal."); } double valNum = 0; string pattern2 = @"(-)?[0-9]{1,}((.)[0-9]{1,})?"; Regex exp2 = new Regex(pattern2); if(exp2.IsMatch(valNum.ToString())) { Console.WriteLine(""); Console.WriteLine("El Número: {0}",valNum.ToString()+" es valido"); } else { Console.WriteLine(""); Console.WriteLine("El Número: {0}",valNum.ToString()+" No es valido"); } } } }
run
|
edit
|
history
|
help
0
JSON Seeder
Foreach
calc
Tttt
aszasxsdf
Problem3 Binary
054325462
Math 10.94 test
Planet-D ver. 0.7
number to words in lithuanian