You may use
string valuesReq = Regex.Split(x, @“\D+\d+”);
Out put will be a array that contains some empity string and last value of your string ,in your case “tablet”.To aviod empty space use if condition !string.IsNullOrEmpty in loop.
And if you to get all string values splited on the bases of numbers then use
string valuesReq = Regex.Split(x, @“\d+”);
it will reurn an array that contain values voltaren,mg and tablet
And to get only numbers from you string use
string valuesReq = Regex.Split(x, @“\D+”);
It will retrun number present in your string, using those you can get indiex and use split after that,
And to remove last string use
string valuesReq = Regex.Split(x.Trim(), @“\D+$”);
Output : “voltaren 50 mg 20”
thanks for your reply!
Input: voltaren 50 mg 20 tablet.
1st Output: remove all words after last number: voltaren 50 mg 20
2nd Input: voltaren 50 mg 20
2nd Output: remove this last number: voltaren 50 mg
3rd input: voltaren 50 mg
3rd Output: same as step 1, remove all words after last number: voltaren 50
Hi Gagaru,
thanks for your help but I don’t Need the last value of my string, I need anything after the last number, which makes it more tricky. So far no one managed to find the solution.
Furthermore, the output needs to be a string and not an array.
Thanks
G.