How to get last 7 digits in string

How to get Last 7 characters in a variable

1 Like

Hi @chec,

Try below code
string temp = "jsgdkdb1234567"
temp.Substring(temp.Length-7)

Regards,
Arivu

17 Likes

What @arivu96 suggested is a great and simplest approach, you can try this as well if you are comfortable with Regex

var result = Regex.Match(yourStringVar,@"(.{7})\s*$");

Thanks,
Prankur

9 Likes

@arivu96,@PrankurJoshi ThankYou Guys

3 Likes

Excelente, Muchas Gracias

2 Likes