How to

remove formatting from numerical string

Published: 1. December 2011 | Updated: 1. December 2011
License: Microsoft Public License (MS-PL)
Categories: Framework » Strings
Tags: C# Formatting Text
Was this snippet helpful for you? YESYES / NONO

Import namespace

using System.Linq;

Code

string text = "+0001 (234) 5678-900";
string number = new string(text.Where(Char.IsDigit).ToArray());

Console.WriteLine(number);
Console Output:
00012345678900
Send us feedback about this snippet »



Related Snippets: