Powershell中的什么命令替换了grep -o(它只显示一行的匹配部分而不是整行)?我尝试使用Select-Object但它总是显示实线.例如:
下一行
<a id="tm_param1_text1_item_1" class="tm_param1param2_param3 xxx_zzz qqq_rrrr_www_vv_no_empty" >eeee <span id="ttt_xxx_zzz">0</span></a>
Run Code Online (Sandbox Code Playgroud)
使用下一个命令:
cat filename | grep -o '>[0-9]' | grep -o '[0-9]'
Run Code Online (Sandbox Code Playgroud)
输出:0
当我使用Select-Object时,我总能看到全线(
一种方法是:
$a = '<a id="tm_param1_text1_item_1" class="tm_param1param2_param3 xxx_zzz qqq_rrrr_www_vv_no_empty" >eeee <span id="ttt_xxx_zzz">0</span></a>'
$a -match '>([0-9])<' #returns true and populate the $matches automatic variable
$matches[1] #returns 0
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1238 次 |
最近记录: |