String manipulation for extract last 7 letters

For example, this is my string “cnp28sep21”,in that How to extract the seven letters? Guide me to complete the task

Hi @Iswarya_P1 ,

image

Regards,

Assuming a variable1 has “Cnp28sep21”
You can use this expression to get the date correctly everytime, if that are the last 7 characters everytime.

variable1.Substring(variable1.Count-7)

Thanks,
Happy Automation

grafik

System.Text.RegularExpressions.Regex.Match(YourStringVar, ".{7}$").Value

Hi,

FYI, another approach:

Right(yourString,7)

image

Regards,

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.