-ccontains

CContains is a conditional operator that will test for the existence of one item in a collection, array or hashtable.

Syntax
      expression -ccontains expression

ccontains is an exact (but case-sensitive) match and will ignore wildcards.

To examine the contents of values within a string, either use a wildcard -match or -split the string into an array.

This operator returns True or False.

Examples

PS C:\> $demoArray = 'alpha', 'beta', 'New York'
PS C:\> $demoArray -ccontains "alpha"
True
PS C:\> $demoArray -ccontains 'New'
False
PS C:\> $demoArray -ccontains 'New york'
False

PS C:\> $string = 'alpha, beta, California'
PS C:\> $string -ccontains 'alpha'
False
PS C:\> $string -split ',' -ccontains 'alpha'
True

“Do I contradict myself? Very well, then I contradict myself, I am large, I contain multitudes” ~ Walt Whitman

Related:

-contains - Case insensitive -contains
-eq - Equality comparison Operator
Syntax - Comparison Operators


© Copyright SS64.com 1999-2014
Some rights reserved