Regular expression to split string into equal length chunks
c#, regex
Solution
What about:
string input ="ece4241692a1c7434da51fc1399ea2fa155d4fc983084ea59d1455afc79fafed";
string target = "<" + Regex.Replace(input, "(.{8})", "$1 ").Trim() + ">";
Or
string another = "<" + String.Join(" ", Regex.Split(input, "(.{8})")) + ">";
Problem
I have a string which would be delivered to my application in the format below: ``` ece4241692a1c7434da51fc1399ea2fa155d4fc983084ea59d1455afc79fafed ``` What I need to do is format it for my database so it reads as follows: ``` <ece42416 92a1c743 4da51fc1 399ea2fa 155d4fc9 83084ea5 9d1455af c79fafed> ``` I assume the easiest way to do this would be using regular expressions, but I have never used them before, and this is the first time I have ever needed to, and to be honest, I simply don't have the time to read up on them at the moment, so if anyone could help me with this I would be eternally grateful.