What patterns does PowerShell -like operator support?

前端 未结 1 344
被撕碎了的回忆
被撕碎了的回忆 2021-01-04 15:09

I was not able to find any reference about syntax of the PowerShell -like operator.

Windows PowerShell reference on comparison operators states only:

1条回答
  •  时光说笑
    2021-01-04 15:25

    The help for about_Comparison_Operators indeed claims wildcard support. It fails to specify what, exactly, a wildcard is.

    -Like Description: Match using the wildcard character (*).

    Further digging into help about_Wildcards we learn that these aren't your grandpa's wildcards:

    Windows PowerShell supports the following wildcard characters.
    
        Wildcard Description        Example  Match             No match
        -------- ------------------ -------- ----------------- --------
        *        Matches zero or    a*       A, ag, Apple      banana
                 more characters
    
        ?        Matches exactly    ?n       an, in, on        ran
                 one character in 
                 the specified 
                 position
    
        [ ]      Matches a range    [a-l]ook book, cook, look  took
                 of characters
    
        [ ]      Matches specified  [bc]ook  book, cook        hook
                 characters
    

    The link to wildcard help is mentioned on the See also -section in about_Comparision_Operators help.

    0 讨论(0)
提交回复
热议问题