Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to strip invalid characters from a string

I am trying to modify a program on Windows CE 5.0 device that scans barcode for dates.. What is the best way to strip invalid string from the date format

example:

2014/03/12 --> 20140312
2014.03.12 --> 20140312
2014-03-12 --> 20140312

What I want is to automatically remove those strings(/,-,.)

Thanks!

like image 380
QKWS Avatar asked Feb 13 '23 13:02

QKWS


1 Answers

Use:

Regex.Replace("2014/03/12", "[^0-9]", string.Empty)
like image 110
Kirill Polishchuk Avatar answered Feb 16 '23 03:02

Kirill Polishchuk