我尝试使用以下方法获取当前目录中每个文件的translator.t('和')之间的所有字符串:
get-childitem . -include *.ts -rec | select-string -pattern "(?<=translator.t\(\')(.*)(?=\'\))"它不工作,它放在外壳上(例如)
app\services\fxutils.service.ts:855: return this.translator.t('setup_flags');
app\services\fxutils.service.ts:857: return this.translator.t('zone1_setup');
app\services\fxutils.service.ts:859: return this.translator.t('zone2_setup');
app\services\fxutils.service.ts:892: return this.translator.t('0');
app\services\fxutils.service.ts:894: return this.translator.t('1');
app\services\fxutils.service.ts:904: return this.translator.t('scenario') + ' ' + v
app\services\fxutils.service.ts:908: return this.translator.t('sequence') + ' A';
app\services\fxutils.service.ts:910: return this.translator.t('sequence') + ' B';
app\services\fxutils.service.ts:918: return this.translator.t('scenario') + ' ' + v
app\services\fxutils.service.ts:922: return this.translator.t('sequence') + ' A';
app\services\fxutils.service.ts:924: return this.translator.t('sequence') + ' B';
app\services\fxutils.service.ts:931: return this.translator.t('-1');
app\services\fxutils.service.ts:941: tmp.vlm = this.translator.t('-1');
app\services\fxutils.service.ts:946: tmp.vlt = this.translator.t('-1');
app\services\fxutils.service.ts:1017: return this.translator.t('scenario') + ' ' + num;
app\services\fxutils.service.ts:1025: else if (val.vlm == 101) return this.translator.t('reset_
app\services\fxutils.service.ts:1026: else if (val.vlm == 102) return this.translator.t('reset_
app\services\fxutils.service.ts:1027: else return this.translator.t('no_action');
app\services\fxutils.service.ts:1035: else if (val.vlm == 101) vlm = this.translator.t('reset_u
app\services\fxutils.service.ts:1036: else if (val.vlm == 102) vlm = this.translator.t('reset_d
app\services\fxutils.service.ts:1037: else vlm = this.translator.t('no_action');
app\services\fxutils.service.ts:1040: else vlt = this.translator.t('no_action');
app\services\fxutils.service.ts:1046: else if (num == 0) return this.translator.t('cmd_disarm')
app\services\fxutils.service.ts:1047: else if (num == 1) return this.translator.t('cmd_arm');
app\services\fxutils.service.ts:1052: else if (num == 1) return this.translator.t('t1');
app\services\fxutils.service.ts:1053: else if (num == 2) return this.translator.t('t2');
app\services\fxutils.service.ts:1054: else if (num == 3) return this.translator.t('t3');
app\services\fxutils.service.ts:1057: if (num == -1) return this.translator.t('no_action');
app\services\fxutils.service.ts:1061: if (num == -1) return this.translator.t('no_action');
app\services\fxutils.service.ts:1062: else if (num == 1) return this.translator.t('disable');但我只想匹配并在外壳中加上以下单词: setup_flags,zone1_setup等.
我怎么能拿到这个?
发布于 2017-04-13 13:00:34
您必须访问从Matches cmdlet返回的Select-String属性:
get-childitem . -include *.ts -rec |
select-string -pattern "(?<=translator.t\(\')(.*)(?=\'\))" |
ForEach-Object {
$_.Matches.Groups[1].value
}https://stackoverflow.com/questions/43392867
复制相似问题