Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Regex
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
Re: Regex
Miscellaneous
Thread ID:
01639151
Message ID:
01639171
Views:
57
Well, I tried to reply earlier but I have problems with UT :(

This is a bad C# code (I wrote it in VFP before I realized this was a .net forum)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RegExpTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(ICRFormat("16Mh1234"));
            Console.WriteLine(ICRFormat("15D35999"));
            Console.WriteLine(ICRFormat("115D35999"));
            Console.Read();
        }

        static String ICRFormat(String UnformattedICR)
        {
            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("^(\\d\\d)([A-Z]{1,2})(\\d{1,6})$", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            System.Text.RegularExpressions.MatchCollection matches = regex.Matches(UnformattedICR);
            if (matches.Count == 1)
            {
                System.Text.RegularExpressions.Match match = matches[0];
                return match.Groups[1] + " " + match.Groups[2].ToString().ToUpper() + " " + match.Groups[3];
            }
            return "Invalid Entry";
        }
    }
}
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform