0

I need some helüp regarding regex.

I have this Input

$input=@("Microsoft Windows Server 2003, Standard Editon", "Microsoft Windows Server 2003 Standard Editon")

what I want is that Ouput

$input.Replace($pattern,"R2")

Microsoft Windows Server 2003 R2 Standard Editon

Microsoft Windows Server 2003 R2 Standard Editon

#

I do not know how to create the $pattern for this one...

Please can u help me

Kind Regards

4

2 回答 2

0
   @("Microsoft Windows Server 2003, Standard Editon", "Microsoft Windows Server 2003 Standard Editon") | % {$_ -replace "\d+", "2003 R2"}
于 2013-10-31T13:27:10.593 回答
0

如果你真的只想在所有“标准”之前添加一个“R2”,试试这个:

,? (?=Standard)

我认为这完全符合您的要求。

( ?=Standard)抓住“标准”背后的内容。

尝试使用在线正则表达式测试器,例如regexpal.com来测试您的代码。

于 2013-10-29T15:45:22.593 回答