I have the following strings:
string a = "1. testdata";
string b = "12. testdata xxx";
What I would like is to be able to extract the number into one string and the characters following the number into another. I tried using .IndexOf(“.”) and then remove, trim and
substrings. If possible I would like to find something simpler as I have this to do in a
lot of parts of my code.
Proposed solutions so far are not correct.
First, after Split(‘.’) or Split(“.”) you will have space in the beginning of second substring.
Second, if you have more than one dot – you’ll have to do something yet after the split.
More robust solution is below:
Argument 2 specifies maximum number of strings to return. Thus when you have several dots – it will make a split only at the first.