i want to parse a string to get second last character from a string. Here is what i am trying to parse
[XX] G_RIMN_4000+_OLEPHI_700+ [InstalmentScheme 1]
From above string i want to get the second last character whether it is single digit or double digit
so e.g 1] i want 1 or 26] i want 26
I tried following approach
string input = "[XR] Z_Prem_4000+_Delphi_700+ [InstalmentScheme 1]";
var words = input.Split(' ');
var reqWord = "";
if(words.Length > 1)
reqWord = words[words.Length-1];
Console.WriteLine (reqWord);
i am getting 1]
as result but i want whatever digit before last ] in a string
2
Answers
You can parse the string using a regular expression, like this:
Without using RegularExpressions you can write this