Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Extract only numbers from String

$
0
0

Hello All,

I have a requirement where I have to update valid phone numbers from bulk users.

To test if it valid, I have to check the length of only the numerals (it should 11 to 12 max)

For ex:

$a = (+1) 201 839 8419

In the above example all the special characters and space has to be removed (final result should be 12018398419), I don't want to use multiple replace command and want to do it through regex, could you please help??

The below command is not working

string result = Regex.Replace($b, @"[^\d]","");

Any help please??


Never giveup till you get what to want.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>