【发布时间】:2020-08-07 13:05:03
【问题描述】:
我在 Powershell 中使用正则表达式。我有一个非捕获组,但它仍然显示在我的结果中。
字符串是:
Grid1.Data = [['TRE - Significant Flux','EG Report','w939909','59e8a31f-d9e9-4ebf-a027-929ec62953ac'],['CB - Daily OD Report','EG Report','w9
39909','59e8a31f-d9e9-4ebf-a027-929ec62953ac'],['BC - Balance Transfers Daily - DRAFT','BC - Balance Transfers Daily - DRAFT','w939909','59e8
a31f-d9e9-4ebf-a027-929ec62953ac'],['CB - CL Activity Report','CB - CL Activity Report','w939909','59e8a31f-d9e9-4ebf-a027-929ec62953ac']]
正则表达式是:
$regex = "(?:\[').*?(?=')"
它仍然返回类似 ['TRE - 重要通量
我需要排除开头的“['”。单引号末尾的非捕获组正在工作。
【问题讨论】:
-
如果powershell支持,可以使用
look-behind。 -
您的正则表达式有一些错误,
[没有转义。 -
用\(?:\[')转义
标签: regex powershell powershell-2.0