Extract only last 4 characters of a string

I am trying to extract the last four digits of a string. The string is in this format: lastname,firstname-XXXX the XXXX are 4 numbers. I tried using a split function to extract everything after the “-” but sometimes the lastname and firstname have a “-” in them. So, I just need a simple way to always extract the last four numbers of the string.

Thanks in advance!

You can use regex like this:
System.Text.RegularExpressions.Regex.Match("LastName,Name-0000", "\d{4}").Value

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