且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 PowerShell 提取子字符串

更新时间:2023-02-03 09:21:14

-match 运算符测试一个正则表达式,将它与魔术变量 $matches 结合起来得到你的结果

The -match operator tests a regex, combine it with the magic variable $matches to get your result

PS C:\> $x = "----start----Hello World----end----"
PS C:\> $x -match "----start----(?<content>.*)----end----"
True
PS C:\> $matches['content']
Hello World

如果对 regex-y 有疑问,请查看此站点:http://www.regular-expressions.信息

Whenever in doubt about regex-y things, check out this site: http://www.regular-expressions.info