fabio santos fabio santos - 1 month ago 6
Vb.net Question

VB or Kofax Script format string

When I have more than one "xxx.xxx.xx" or "xxx,xxx,xx" how i can replace all to result in this format (1000,12)? I just need an exemple the language is not important.



Input test case:

1000 .12

1,000.12

1.000.12

1,000,12

1000,,12

1000.12



Output:
1000,12

Answer

Try this

            string[] inputs = { "1000.12", "1,000.12", "1.000.12", "1,000,12", "1000,,12", "1000.12" };
            for (int i = 0; i < inputs.Count(); i++)
            {
                inputs[i] = inputs[i].Replace(".", "");
                inputs[i] = inputs[i].Replace(",", "");

                string output = inputs[i].Substring(0, inputs[i].Length - 2) + "," + inputs[i].Substring(inputs[i].Length - 1);
                Console.WriteLine(output);
            }
            Console.ReadLine();