标题: 【有偿】批处理怎样提取txt文本中包含指定字符后面的内容 [打印本页]
作者: wypenn 时间: 2022-5-11 10:45 标题: 【有偿】批处理怎样提取txt文本中包含指定字符后面的内容
我想获取TXT中 data-fakeid= 后面双引号里的字符串 o9r3EjjnPfKvHga5j6yDPAeC_0ss 并换行输出到b.txt 下面是示例的文件 谢谢!
[code]<tbody class="tbody" id="userGroups">
<tr>
<td class="table_cell user">
<div class="user_info"> <!--个人信息区-->
<a target="_blank" href="/cgi-bin/singlesendpage?t=message/send&action=index&tofakeid=o9r3EjjnPfKvHga5j6yDPAeC_0ss&token=873879282&lang=zh_CN" class="remark_name" data-fakeid="o9r3EjjnPfKvHga5j6yDPAeC_0ss">银子</a>
<span class="nick_name" data-fakeid="o9r3EjjnPfKvHga5j6yDPAeC_0ss"></span>
<a target="_blank" href="/cgi-bin/singlesendpage?t=message/send&action=index&tofakeid=o9r3EjjnPfKvHga5j6yDPAeC_0ss&token=873879282&lang=zh_CN" class="avatar">
<img src="/misc/getheadimg?fakeid=o9r3EjjnPfKvHga5j6yDPAeC_0ss&token=873879282&lang=zh_CN" data-id="o9r3EjjnPfKvHga5j6yDPAeC_0ss" class="js_msgSenderAvatar">
</a>
<label for="checko9r3EjjnPfKvHga5j6yDPAeC_0ss" class="frm_checkbox_label"><i class="icon_checkbox"></i><input class="frm_checkbox js_select" type="checkbox" value="o9r3EjjnPfKvHga5j6yDPAeC_0ss" id="checko9r3EjjnPfKvHga5j6yDPAeC_0ss"></label>
<div class="js_tags user_tag_area">
<span class="js_tags_list user_tag_list">
<span class="js_tags_short"><a href="javascript:;" class="js_user_tags user_tag" data-id="134">2022-1</a></span>
<span class="js_tags_total" style="display: none;"><a href="javascript:;" class="js_user_tags user_tag" data-id="134">2022-1</a></span>
</span>
<span class="js_tags_btn dropdown_switch_area dropdown_closed" data-id="o9r3EjjnPfKvHga5j6yDPAeC_0ss">
<span class="icon_dropdown_switch">
<i class="arrow arrow_up"></i>
<i class="arrow arrow_down"></i>
</span>
</span>
</div>
</div>
</td>
<td class="table_cell user_opr tr">
<div id="selectAreao9r3EjjnPfKvHga5j6yDPAeC_0ss" class="js_selectArea" data-gid="" data-fid="o9r3EjjnPfKvHga5j6yDPAeC_0ss"></div>
<a class="btn remark js_msgSenderRemark" data-fakeid="o9r3EjjnPfKvHga5j6yDPAeC_0ss">修改备注</a>
</td>
</tr>
<tr>
<td class="table_cell user">
<div class="user_info"> <!--个人信息区-->
<a target="_blank" href="/cgi-bin/singlesendpage?t=message/send&action=index&tofakeid=o9r3EjsU1fuIzfIqN0enXzwtJ_TA&token=873879282&lang=zh_CN" class="remark_name" data-fakeid="o9r3EjsU1fuIzfIqN0enXzwtJ_TA">麦麦</a>
<span class="nick_name" data-fakeid="o9r3EjsU1fuIzfIqN0enXzwtJ_TA"></span>
<a target="_blank" href="/cgi-bin/singlesendpage?t=message/send&action=index&tofakeid=o9r3EjsU1fuIzfIqN0enXzwtJ_TA&token=873879282&lang=zh_CN" class="avatar">
<img src="/misc/getheadimg?fakeid=o9r3EjsU1fuIzfIqN0enXzwtJ_TA&token=873879282&lang=zh_CN" data-id="o9r3EjsU1fuIzfIqN0enXzwtJ_TA" class="js_msgSenderAvatar">
</a>
<label for="checko9r3EjsU1fuIzfIqN0enXzwtJ_TA" class="frm_checkbox_label"><i class="icon_checkbox"></i><input class="frm_checkbox js_select" type="checkbox" value="o9r3EjsU1fuIzfIqN0enXzwtJ_TA" id="checko9r3EjsU1fuIzfIqN0enXzwtJ_TA"></label>
<div class="js_tags user_tag_area">
<span class="js_tags_list user_tag_list">
<span class="js_tags_short"><a href="javascript:;" class="js_user_tags user_tag" data-id="134">2022-1</a></span>
<span class="js_tags_total" style="display: none;"><a href="javascript:;" class="js_user_tags user_tag" data-id="134">2022-1</a></span>
</span>
<span class="js_tags_btn dropdown_switch_area dropdown_closed" data-id="o9r3EjsU1fuIzfIqN0enXzwtJ_TA">
<span class="icon_dropdown_switch">
<i class="arrow arrow_up"></i>
<i class="arrow arrow_down"></i>
</span>
</span>
</div>
</div>
</td>
<td class="table_cell user_opr tr">
<div id="selectAreao9r3EjsU1fuIzfIqN0enXzwtJ_TA" class="js_selectArea" data-gid="" data-fid="o9r3EjsU1fuIzfIqN0enXzwtJ_TA"></div>
<a class="btn remark js_msgSenderRemark" data-fakeid="o9r3EjsU1fuIzfIqN0enXzwtJ_TA">修改备注</a>
</td>
</tr>
<tr>
<td class="table_cell user">
<div class="user_info"> <!--个人信息区-->
<a target="_blank" href="/cgi-bin/singlesendpage?t=message/send&action=index&tofakeid=o9r3Ejt5kk2L3dFaO2su_i1LaxzE&token=873879282&lang=zh_CN" class="remark_name" data-fakeid="o9r3Ejt5kk2L3dFaO2su_i1LaxzE">小郭吃不胖🤭</a>
<span class="nick_name" data-fakeid="o9r3Ejt5kk2L3dFaO2su_i1LaxzE"></span>
<a target="_blank" href="/cgi-bin/singlesendpage?t=message/send&action=index&tofakeid=o9r3Ejt5kk2L3dFaO2su_i1LaxzE&token=873879282&lang=zh_CN" class="avatar">
<img src="/misc/getheadimg?fakeid=o9r3Ejt5kk2L3dFaO2su_i1LaxzE&token=873879282&lang=zh_CN" data-id="o9r3Ejt5kk2L3dFaO2su_i1LaxzE" class="js_msgSenderAvatar">
</a>
<label for="checko9r3Ejt5kk2L3dFaO2su_i1LaxzE" class="frm_checkbox_label"><i class="icon_checkbox"></i><input class="frm_checkbox js_select" type="checkbox" value="o9r3Ejt5kk2L3dFaO2su_i1LaxzE" id="checko9r3Ejt5kk2L3dFaO2su_i1LaxzE"></label>
<div class="js_tags user_tag_area">
<span class="js_tags_list user_tag_list">
<span class="js_tags_short"><a href="javascript:;" class="js_user_tags user_tag" data-id="134">2022-1</a></span>
<span class="js_tags_total" style="display: none;"><a href="javascript:;" class="js_user_tags user_tag" data-id="134">2022-1</a></span>
</span>
<span class="js_tags_btn dropdown_switch_area dropdown_closed" data-id="o9r3Ejt5kk2L3dFaO2su_i1LaxzE">
<span class="icon_dropdown_switch">
<i class="arrow arrow_up"></i>
<i class="arrow arrow_down"></i>
</span>
</span>
</div>
</div>
</td>
<td class="table_cell user_opr tr">
<div id="selectAreao9r3Ejt5kk2L3dFaO2su_i1LaxzE" class="js_selectArea" data-gid="" data-fid="o9r3Ejt5kk2L3dFaO2su_i1LaxzE"></div>
<a class="btn remark js_msgSenderRemark" data-fakeid="o9r3Ejt5kk2L3dFaO2su_i1LaxzE">修改备注</a>
</td>
</tr>
<tr>
作者: flashercs 时间: 2022-5-11 11:46
- <#*,:&cls
- @echo off
- cd /d "%~dp0"
- powershell -C "Set-Location -LiteralPath ([Environment]::CurrentDirectory);. ([ScriptBlock]::Create((Get-Content -LiteralPath \"%~f0\" -ReadCount 0 | Out-String)))"
- pause
- exit /b
- #>
- #
- $a = "a.txt"
- $b = "b.txt"
- $encoding = New-Object System.Text.UTF8Encoding -ArgumentList $false
- $re = [regex]'data-fakeid="([^"]*)"'
- $txt = [System.IO.File]::ReadAllText($a, $encoding)
- [system.io.file]::WriteAllLines($b, $(foreach ($m in $re.Matches($txt)) {
- $m.Groups[1].Value
- }), $encoding)
复制代码
作者: wypenn 时间: 2022-5-11 12:14
回复 3# flashercs
可以用 已转账 感谢 感谢!
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |