M
Mike Edgewood
One of our most frequently encountered errors in number entry is an
extra digit at the end that doesn't belong. Looking for a
Regex.Replace to go in my DataGridView.CellFormatting.
Regex.Replace(inputStr, _
".*?(\d{3}).*?(\d{3}).*?(\d{4}).*?", "($1) $2-$3)")
The behavior regex.replace is not what I expect.
input: 123-456-78901
returns: (123) 456-78901
The extra digit does not match any pattern within a capture group, so
why is it showing up as part of capture group 3?
input: 1234567890a
returns: (123) 456-7890a
The 3rd capture groups seems to be returning everything rather than
just 4 numeric characters. Running regex.Match returns 3 groups with
correct results, but regex.replace is not producing the same expected
result and is confusing the hell out of me.
I want to keep this as simple and quick as possible because, according
to the documentation, CellFormatting is called on every paint request.
extra digit at the end that doesn't belong. Looking for a
Regex.Replace to go in my DataGridView.CellFormatting.
Regex.Replace(inputStr, _
".*?(\d{3}).*?(\d{3}).*?(\d{4}).*?", "($1) $2-$3)")
The behavior regex.replace is not what I expect.
input: 123-456-78901
returns: (123) 456-78901
The extra digit does not match any pattern within a capture group, so
why is it showing up as part of capture group 3?
input: 1234567890a
returns: (123) 456-7890a
The 3rd capture groups seems to be returning everything rather than
just 4 numeric characters. Running regex.Match returns 3 groups with
correct results, but regex.replace is not producing the same expected
result and is confusing the hell out of me.
I want to keep this as simple and quick as possible because, according
to the documentation, CellFormatting is called on every paint request.