PowerShell:过滤字符串列表 [英] PowerShell: filter string list

查看:61
本文介绍了PowerShell:过滤字符串列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎是一件非常基本的事情,但我是 PowerShell 的新手,无法弄清楚这一点,也无法在网上找到示例...

This seems like a very basic thing to do, but I am new to PowerShell and can't figure this out or find an example online...

我正在尝试过滤字符串列表.此字符串列表是svn list"命令(存储库文件的 Subversion 列表)的结果,例如:

I am trying to filter a list of strings. This list of strings is the result of a "svn list" command (Subversion list of repository files), like:

svn list -R PATHTOREPOSITORY

我试过了

svn list -R PATHTOREPOSITORY | where {$_ -like "stringtomatch"}

这不起作用.我该如何解决?

and this does not work. How can I fix it?

推荐答案

您可以考虑使用 -match 而不是 -like.-Match 更强大(基于正则表达式)并且会像您最初期望的那样工作:

You might consider using -match instead of -like. -Match is more powerful (regex based) and will work like you were initially expecting:

svn list -R PATHTOREPOSITORY | where {$_ -match 'stringtomatch'} 

这篇关于PowerShell:过滤字符串列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆