G
Guest
I have a series of number that need parsed. Strip the zeros, if a caret
exists replace it with a slash.
1.) 000123^2 - should be 123/2
2.) 1^2 - should be 1/2
3.) 0001 - should be 1
4.) 000123 - should be 123
I have this started:
Regex r = new Regex(@"(?<base>[1-9]{1}\d*)\W(?<group>\d*)");
Console.WriteLine(r.Match(value).Result("${base}/${group}"));
I do not know how to do the condtional to exclude the slash on examples 3
and 4. How do I prevent the addition of the slash when there is no caret in
the number?
Thanks!
exists replace it with a slash.
1.) 000123^2 - should be 123/2
2.) 1^2 - should be 1/2
3.) 0001 - should be 1
4.) 000123 - should be 123
I have this started:
Regex r = new Regex(@"(?<base>[1-9]{1}\d*)\W(?<group>\d*)");
Console.WriteLine(r.Match(value).Result("${base}/${group}"));
I do not know how to do the condtional to exclude the slash on examples 3
and 4. How do I prevent the addition of the slash when there is no caret in
the number?
Thanks!