Reputation: 29683
So I will have list of integer strings, I mean, integers converted to strings in my DB like below:
66S12345, 623T4785, 784D3212
So there will be only one occurance of character in the above string.
Now I want to split the string based on the character position and obtain it as S12345, T4785, D3212
. But no idea how to get it.
I obtain list of strings as below
using(var context=new ATMAccountEntities()){
List<string> accountNumbers = new List<string>();
accountNumbers = (from n in context.Students select n.stdUniqueID).ToList();
foreach(var acc in accountNumbers) // acc can be 66S12345, 623T4785, 784D3212
{
string accNum= //Any way to split the string and obtain later part after character
}
};
Upvotes: 0
Views: 51
Reputation: 2653
You can use below regex to resolve it
string obj = "784D3212";
Match match = Regex.Match(obj, @"[A-Z]\d+");
if (match.Success)
obj = match.Value;
Upvotes: 2