Reputation: 623
I am trying to find the right regex to remove just the numbers from the beginning of a string
>from
8012 name last name 123 456
6952332 name last 213 5695
>into
name last name 123 456
name last 213 5695
this is not good cus its matching all
@"[\d-]"
Upvotes: 5
Views: 3909
Reputation: 216353
You need to anchor your pattern to the beginning of the string ^
string pattern = @"^[0-9]+"; // or @"^\d+";
string source = "8012 name last name 123 456";
string newText = Regex.Replace(source, pattern, "");
Upvotes: 7