protected void Page_Load(object sender, EventArgs e)
{
lab.Text = FormatTelephoneNumber("0034523");
}
public static string FormatTelephoneNumber(string value)
{
value = new System.Text.RegularExpressions.Regex(@"\D").Replace(value, string.Empty);
return Convert.ToInt64(value).ToString(" #- ###-###");
}
Gives Output:
34-523
But I need output:
0-034-523
0034523
would Become 0-034-523
and 00345
would become 0-034-5
(no extra valeue or 0- 000-345
)