Categories:
Administration (10)
Adware Spyware (7)
Apache (10)
Bluetooth (125)
DOS Commands (1)
Edge (28)
General (2)
Internet Explorer (217)
Media Center (12)
Media Player (11)
Mozilla Firefox (18)
PHP (15)
Programming (8)
Security (4)
Silverlight (15)
Tips (17)
Tools (218)
Tutorials (5)
Windows 10 (166)
Windows 7 (636)
Windows 8 (1091)
Windows Phone (33)
Windows Server 2008 (165)
Windows Server 2012 (84)
Windows Server 2016 (23)
Windows Vista (52)
Collections:
Other Resources:
String Comparison in Windows PowerShell
How to compare two strings in Windows PowerShell?
✍: FYIcenter.com
Windows PowerShell supports the following string comparison operations:
-eq - Equal to -ne - Not equal to -gt - Greater than -ge - Greater than or equal to -lt - Less than -le - Less than or equal to -Like - Match with wildcard characters ? and * -NotLike - Not match with wildcard characters ? and * -Match - Match with regular expressions -NotMatch - Not match with regular expressions
Note that the above operations are case-insensitive. If you want to perform case-sensitive comparisons, you need to use the following comparison operations:
-ceq - Case-sensitive equal to -cne - Case-sensitive not equal to -cgt - Case-sensitive greater than -cge - Case-sensitive greater than or equal to -clt - Case-sensitive less than -cle - Case-sensitive less than or equal to -cLike - Case-sensitive match with wildcard characters ? and * -cNotLike - Case-sensitive not match with wildcard characters ? and * -cMatch - Case-sensitive match with regular expressions -cNotMatch - Case-sensitive not match with regular expressions
Here are some good examples of string comparison operations:
PS C:\fyicenter> "abc" -eq "Abc" True PS C:\fyicenter> "abc" -ceq "Abc" False PS C:\fyicenter> "abc" -lt "Abc" False PS C:\fyicenter> "abc" -clt "Abc" True PS C:\fyicenter> "anderson" -like "an*n" True PS C:\fyicenter> "anderson" -like "an????n" False PS C:\fyicenter> "anderson" -like "an?n" False PS C:\fyicenter> "anderson" -match "an.*n" True PS C:\fyicenter> "anderson" -NotMatch "an.*n" False
Â
⇒ String Replacement in Windows PowerShell
⇠Expression Expansion in Strings in Windows PowerShell
⇑ Work with Strings in Windows PowerShell
⇑⇑ Windows PowerShell Tutorials
2016-10-19, 1665👍, 0💬
Popular Posts:
How to add a program into the startup folder? If you find an interesting program that you want to ad...
Why I am getting this "Microsoft Silverlight Update" pop up window? If you have Silverlight 2.0 inst...
If you are using a wireless router to connecting to the Internet through a DSL modem, how many IP ad...
How to remove CLI.exe from startup program list? CLI.exe is a configuration program for the ATI grap...
Where to find information about what processes are running on Windows 8 and how to manage them? I wa...