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

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -