PowerShell类似的运营商支持哪些模式?

时间:2014-11-06 11:12:47

标签: powershell operators pattern-matching wildcard

我无法找到有关PowerShell -like运算符语法的任何参考。

comparison operators上的Windows PowerShell参考仅指出:

  


  描述:使用通配符(*)进行匹配。

虽然通过实验我发现它也支持?[](设置)。

是否支持其他语法?是否有-like运算符的确切引用?

1 个答案:

答案 0 :(得分:17)

about_Comparison_Operators的帮助确实声称支持通配符。它无法确切地说明通配符是什么。

  

样         描述:使用通配符(*)进行匹配。

进一步深入了解帮助about_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

关于通配符帮助的链接在about_Comparision_Operators帮助的参见章节中提到。

相关问题