c# - Get last 3 characters of string -


how can last 3 character out given string?

example input: am0122200204

expected result: 204

many ways can achieved.

simple approach should taking substring of input string.

var result = input.substring(input.length - 3); 

another approach using regular expression extract last 3 charcters.

var result = regex.match(input,@"(.{3})\s*$"); 

working demo


Comments

Popular posts from this blog

mongodb - Struggling to get ordered results from the last retrieved article, given array of elements to search in -

c# - Pausing a storyboard on TabItem mouse over -

c# - Attribute value in root node of xml Linq to XML -