using Regular exprestion to validate IP Address in Powershell?

I have this code in PowerShell and it does not work! any help?

I just need it to make sure that the string is a working IP not 999.999.999.999 or a normal string

just an IP [0....255].[0....255].[0....255].[0....255]

if ($newIP -match "(\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b)") { $x = $True}

cheers

6
задан JasonMArcher 24 May 2011 в 16:32
поделиться