Not familiar enough with .NET for exact code. Nonetheless, two approaches would be:
- Cast it as an integer. If the non-digit characters are at the end (i.e.
21389abc), this is the easiest.
- If you have intermixed non-digit characters (i.e.
1231a23v) and want to keep every digit, use the regex [^\d] to replace non-digit characters.