ok so I have this string.
Next: Warrant Officer Grade 2
21,202 / 33,000
21,202 / 33,000
It is a substring I have obtained from a long thing of text. Now “Warrent Officer Grade 2” as well as the numbers can be dynamic (I am loading these variables from a webpage) If there is a number in the ones or hundreds it does not append 0’s so the exp for less than a thousand would look like “478” instead of 00,478.
Now my question is how to I obtain just “Warrant Officer Grade 2”? I already have this
int indexOfNext = myString.IndexOf("Next") + 6;
//Below is what I need to obtain
int count = 0;
string newString = myString.Substring(indexOfNext, count);
But how would I help determine the count for getting the rank? or would It just be simple to create an array with all the ranks and the length of each rank?
You can use regular expression to search for the name and level for example
this will match all lines starting with
Next:followed with the name,Gradeword and level. The captured values ofnameandlevelgroups can be retrieved lateror modify it the way you want it.
Regex playground: Derek Slager’s A Better .NET Regular Expression Tester