简体   繁体   中英

Powershell -like operator confusion

为什么以下Powershell代码给出false而不是true?

"ok" -like "??p*"

Because * is a wildcard/glob and not a regex metacharacter.

Your pattern ??p* isn't saying "any two characters followed by zero-or-more 'p' characters" it is saying "any two characters followed by a 'p' followed by anything".

Your wildcard expression expect at least 3 characters with the third character being a p. As this is not the case the expression will return false.

See http://ss64.com/ps/syntax-wildcards.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM