Check For Numeric Characters

Share |

Join PowerShell.com!
Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Award-winning PowerShellPlus


Admin Guide to PowerShell Remoting


Mastering PowerShell eBook

Try this if you need to check a single character and find out whether or not it is numeric:

PS > [char]::IsNumber('1')
True
PS > [char]::IsNumber('A')
False

 

The type Char has a bunch of other useful methods. Here is a list that you can try:

[char] | Get-Member -static

 

 

Twitter This Tip! ReTweet this Tip!


Posted Jun 21 2011, 08:00 AM by ps1
Copyright 2012 PowerShell.com. All rights reserved.