Greetings,
i have 2 questions as new bee :
Q1. str =“123456” output should be > 123 456
Q2. newStr = " Good morning now 8.00 am and class start at 8.00 pm "
(i have spaces 3 4 5 4 2 4 2 3)
output should be > morning
output should be> 8.00 (for am)
what is be optimal way of doing it and why. Thank you in advance.
For Q1, I would rather rely on String.Format or ToString with culture aware formatting or use invariant culture as describe in SO answer inked below. This can handle number with any count of digits and will format decimal “point” if needed too.
For Q2, you can splt on multiple spaces (if I understood) with a regex:
result = System.Text.RegularExpressions.Regex.Split(myText, "\s+")