Trim leading n alpha characters from string

c#, regex

Solution

Try something like this:

String output = Regex.Replace(input, @"^[^\d]+", String.Empty);

Here is how the regular expression works:

`^[^\d]+`

`^` anchors the expression to the beginning of the string `[^\d]` is a character set matching all non-integral values `+` qualifies `[^\d]` by making it match one or more times

So basically this regular expression matches all non-integral characters in a string up until an integral character is found.

Problem

I need to trim the first n alpha characters from a string. Examples: a123456 -> 123456 abc123456 -> 123456 abc123456def -> 123456def

Original source

Related problems