Beispiel #1
0
        static void TestaString()
        {
            //string padrao = "[0123456789][0123456789][0123456789][0123456789][-][0123456789][0123456789][0123456789][0123456789]";
            //string padrao = "[0-9][0-9][0-9][0-9][-][0-9][0-9][0-9][0-9]";
            //string padrao = "[0-9]{4}[-][0-9]{4}";
            //string padrao = "[0-9]{4,5}[-][0-9]{4}";
            //string padrao = "[0-9]{4,5}[-]{0,1}[0-9]{4}";
            //string padrao = "[0-9]{4,5}-{0,1}[0-9]{4}";
            string padrao = "[0-9]{4,5}-?[0-9]{4}";

            string textoTeste = "Pode me ligar em 94546-3234";
            Match  teste      = Regex.Match(textoTeste, padrao);

            Console.WriteLine(teste.Value);
            Console.ReadLine();

            string urlTeste = "https://www.bytebank.com/cambio";

            Console.WriteLine(urlTeste.StartsWith("https://www.bytebank.com"));
            Console.WriteLine(urlTeste.EndsWith("cambio"));
            Console.WriteLine(urlTeste.Contains("bytebank"));
            Console.ReadLine();

            string urlParametros             = "http://www.bytebank.com/cambio?moedaOrigem=real&moedaDestino=dolar";
            ExtratorDeArgumentosURL extrator = new ExtratorDeArgumentosURL(urlParametros);
            string valor  = extrator.GetValor("MoEdaOrigem");
            string valor2 = extrator.GetValor("moedadesTino");

            Console.WriteLine("Valor de moedaOrigem: " + valor);
            Console.WriteLine("Valor de moedaDestino: " + valor2);
        }
Beispiel #2
0
        public static void ExtrairValorCambio()
        {
            string url = "www.bytebank.com/cambio?moedaOrigem=real&moedaDestino=dolar&valor=1500";

            ExtratorDeArgumentosURL extrator = new ExtratorDeArgumentosURL(url);

            Console.WriteLine(extrator.GetValor("moedaOrigem"));  // real
            Console.WriteLine(extrator.GetValor("moedaDestino")); // dolar
            Console.WriteLine(extrator.GetValor("valor"));        // 1500
        }