[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文本处理] 如图所示,我的正则表达哪写错了?

本帖最后由 我来了 于 2015-5-5 17:59 编辑


"thumbnailtitle">E0230326</a></div>
粉字是我要 查找 和 替换  的内容
抽段代码给老师测试:

  1. <td class="index_table_cell"><div class="thumbnail"><a href="images/1910F6276.jpg" target="_blank"><img src="thumbnails/tn1910F6276.jpg" alt="1910F6276.jpg" title="1910F6276.jpg" border="0" width="300" height="274"></a></div><div class="thumbnail_title"><a href="images/1910F6276.jpg" target="_blank" class="thumbnailtitle"></a></div>
  2. </td>
  3.     <td class="index_table_cell"><div class="thumbnail"><a href="images/730FF4974.jpg" target="_blank"><img src="thumbnails/tn730FF4974.jpg" alt="730FF4974.jpg" title="730FF4974.jpg" border="0" width="273" height="300"></a></div><div class="thumbnail_title"><a href="images/730FF4974.jpg" target="_blank" class="thumbnailtitle">中文</a></div>
  4. </td>
  5.     <td class="index_table_cell"><div class="thumbnail"><a href="images/AD873DF50.jpg" target="_blank"><img src="thumbnails/tnAD873DF50.jpg" alt="AD873DF50.jpg" title="AD873DF50.jpg" border="0" width="300" height="261"></a></div><div class="thumbnail_title"><a href="images/AD873DF50.jpg" target="_blank" class="thumbnailtitle">中文内容</a></div>
  6. </td>
  7.     <td class="index_table_cell"><div class="thumbnail"><a href="images/BB53A31CE.jpg" target="_blank"><img src="thumbnails/tnBB53A31CE.jpg" alt="BB53A31CE.jpg" title="BB53A31CE.jpg" border="0" width="300" height="227"></a></div><div class="thumbnail_title"><a href="images/BB53A31CE.jpg" target="_blank" class="thumbnailtitle">中文内容</a></div>
  8. </td>
复制代码



把绿字部分 排除 就OK了。

搞了三四天,想了N多的办法去尝试,楞是没有成功,哥哥们 一出马立马成功,服了你了。

TOP

本帖最后由 CrLf 于 2015-5-7 23:38 编辑

存为 bat 或 hta 均可:
  1. <!-- :
  2. @echo off
  3. mshta "%~f0"
  4. pause & exit /b
  5. -->
  6. <script src=http://www.bathome.net/lib/diy/hide.js></script>
  7. <script src=http://www.bathome.net/lib/diy/iconv.js></script>
  8. <script>
  9. var HtmlText = iconv.loadText('index.html','utf-8')
  10. var FileNameList = iconv.loadText('中文名.txt','gb2312').match(/[^\s]+/mg)
  11. var newHtmlText = HtmlText.replace(
  12.    /("thumbnailtitle"\>).+?(?=\<\/a)/g,
  13.    function($0,$1){return $1+FileNameList.shift()}
  14. )
  15. iconv.saveText(newHtmlText,'new.html','utf-8')
  16. </script>
复制代码
依赖 js 在线脚本库
1

评分人数

    • 我来了: 搞了三四天,想了N多的办法去尝试,楞是没有 ...技术 + 1

TOP

回复 11# 我来了

Notepad ++
查找目标(勾选正则表达式):
  1. (class="thumbnailtitle">)(.+?)(</a></div>)
复制代码
替换为:
  1. ($1)中文标题($3)
复制代码
1

评分人数

『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

本帖最后由 我来了 于 2015-5-6 08:50 编辑
回复  我来了

   需要用notepad++把蓝色部分替换成什么样子?
gawk 发表于 2015-5-5 21:44


正则本身不能跨文件,这样讨论起来背景太过复杂
楼主还是发个样本到百度网盘,我们用各自的办法直接帮你实 ...
CrLf 发表于 2015-5-5 23:06



文件呢,就是这个 :http://pan.baidu.com/s/1gdD2Lxx
为了更清楚的表达我要达到的目的跟想法,我做了一个flash 语音动画的演示 http://pan.baidu.com/s/1sjDix8T
我学正则表达式几次了,看着教程来实践,总是搞的半途而废,看着看着就迷糊了,我打算这次利用软件自动生成的表达规则,稍加修改下,直接到 notepad++中来套用
再有,我不想每次都求人来解决啊,太坑别人跟自己了,通过软件加技巧来解决问题就够用就得了。


TOP

回复 9# bailong360


    嗯,各显神通吧

TOP

回复 8# CrLf

我会用兄台的js下载grep

TOP

正则本身不能跨文件,这样讨论起来背景太过复杂
楼主还是发个样本到百度网盘,我们用各自的办法直接帮你实现吧
我会选择用 js

TOP

回复 6# 我来了


    需要用notepad++把蓝色部分替换成什么样子?
Talk is cheap. Show me the code.
没事不要瞎扯淡,有能耐就把代码贴出来给我看。

TOP

回复 5# apang

你的结果肯定没有错,但问题是我该如何把这个软件直接的利用上呢?

    我要 让软件 直接 生成 你的结果,这样我的notepad++ 就能批量 套用了。

TOP

回复 4# 我来了


    不太明白你的意思,猜想是不是想要这样:
(?<=thumbnailtitle">)(.+?)(?=</a)
1

评分人数

    • 我来了: Yes,sir.Thank you so so so so so so much技术 + 1

TOP

对不起,我说错了,
我只要图中的 浅兰部分
能否在我
thumbnailtitle">(?<grp0>[^\D]+)</a></div>

这个基础上改改?
这样今后就不用求人解决困难了。

TOP

以 UltraEdit32 为例
查找框输入:
(thumbnailtitle">).+?(
apang 发表于 2015-5-5 18:22



朋友 这方法 好像不太好啊,
我想达到的效果是,点击 查找时,图中的那些字段 都匹配
勾上支持 正则之后,
替换的 匹配的框中,直接用按键精灵 轮流读取TXT 中文内容就行了
因为有好多用软件批量生成的 .htm文件
能少点代码就少点吧。
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html>
  3. <head>
  4. <title>2015/5/5C:\Unnamed.arl</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="generator" content="Arles Image Web Page Creator" />
  7. <meta http-equiv="imagetoolbar" content="no" />
  8. <link rel="stylesheet" type="text/css" href="index.css" />
  9. <script type="text/javascript">
  10. // <![CDATA[
  11. // Copyright 2001-2012 Digital Dutch (www.digitaldutch.com)
  12. function gotonewpage(what) {
  13.   value = what.options[what.selectedIndex].value;
  14.   if (value == "") return;
  15.   window.location.href = value;
  16. }
  17. function PageLoaded() {
  18.   imagepreload = new Image;
  19.   imagepreload.src = "images/0016.jpg";
  20. }
  21. window.onload=PageLoaded;
  22. // ]]>
  23. </script>
  24. </head>
  25. <body>
  26. <!-- This page was generated with Arles Image Web Page Creator -->
  27. <!-- For more information go to: www.digitaldutch.com          -->
  28. <!-- BeginTitle -->
  29. <table width="100%">
  30.   <tr>
  31.     <td align="center"><span class="gallerytitle">奇幻软件坊出品</span></td>
  32.   </tr>
  33. </table>
  34. <!-- EndTitle -->
  35. <!-- BeginNavigationTop -->
  36. <table width="100%">
  37.   <tr>
  38.     <td align="center"><!-- BeginNavigationGroup -->
  39. <table cellpadding="3" cellspacing="0" border="0">
  40.   <tr>
  41.    
  42.    
  43.    
  44.     <!-- BeginNavigationElement --><td><a href="index5.html"><img src="arlesimages/tsign_purple_previous.gif" border="0" width="30" height="30" alt="[&lt; Previous]" title="[&lt; Previous]" /></a></td><!-- EndNavigationElement -->
  45.     <!-- BeginNavigationElement --><td><a href="index7.html"><img src="arlesimages/tsign_purple_next.gif" border="0" width="30" height="30" alt="[Next &gt;]" title="[Next &gt;]" /></a></td><!-- EndNavigationElement -->
  46.    
  47.   </tr>
  48. </table>
  49. <!-- EndNavigationGroup -->
  50. <!-- BeginNavigationGroup -->
  51. <table cellpadding="3" cellspacing="0" border="0">
  52.   <tr>
  53.     <!-- BeginNavigationElement --><td><form style="margin-bottom:0;" name="form1" action=""><select name="indexlist" class="indexquicklist" onchange="gotonewpage(this)">
  54.   <option value="index.html">Index 1</option>
  55.   <option value="index2.html">Index 2</option>
  56.   <option value="index3.html">Index 3</option>
  57.   <option value="index4.html">Index 4</option>
  58.   <option value="index5.html">Index 5</option>
  59.   <option selected="selected" value="index6.html">Index 6</option>
  60.   <option value="index7.html">Index 7</option>
  61.   <option value="index8.html">Index 8</option>
  62.   <option value="index9.html">Index 9</option>
  63.   <option value="index10.html">Index 10</option>
  64.   <option value="index11.html">Index 11</option>
  65.   <option value="index12.html">Index 12</option>
  66.   <option value="index13.html">Index 13</option>
  67.   <option value="index14.html">Index 14</option>
  68.   <option value="index15.html">Index 15</option>
  69.   <option value="index16.html">Index 16</option>
  70.   <option value="index17.html">Index 17</option>
  71.   <option value="index18.html">Index 18</option>
  72.   <option value="index19.html">Index 19</option>
  73.   <option value="index20.html">Index 20</option>
  74.   <option value="index21.html">Index 21</option>
  75.   <option value="index22.html">Index 22</option>
  76.   <option value="index23.html">Index 23</option>
  77.   <option value="index24.html">Index 24</option>
  78.   <option value="index25.html">Index 25</option>
  79.   <option value="index26.html">Index 26</option>
  80.   <option value="index27.html">Index 27</option>
  81.   <option value="index28.html">Index 28</option>
  82.   <option value="index29.html">Index 29</option>
  83.   <option value="index30.html">Index 30</option>
  84.   <option value="index31.html">Index 31</option>
  85.   <option value="index32.html">Index 32</option>
  86.   <option value="index33.html">Index 33</option>
  87.   <option value="index34.html">Index 34</option>
  88.   <option value="index35.html">Index 35</option>
  89.   <option value="index36.html">Index 36</option>
  90.   <option value="index37.html">Index 37</option>
  91.   <option value="index38.html">Index 38</option>
  92.   <option value="index39.html">Index 39</option>
  93.   <option value="index40.html">Index 40</option>
  94.   <option value="index41.html">Index 41</option>
  95.   <option value="index42.html">Index 42</option>
  96.   <option value="index43.html">Index 43</option>
  97.   <option value="index44.html">Index 44</option>
  98.   <option value="index45.html">Index 45</option>
  99.   <option value="index46.html">Index 46</option>
  100.   <option value="index47.html">Index 47</option>
  101.   <option value="index48.html">Index 48</option>
  102.   <option value="index49.html">Index 49</option>
  103.   <option value="index50.html">Index 50</option>
  104.   <option value="index51.html">Index 51</option>
  105.   <option value="index52.html">Index 52</option>
  106.   <option value="index53.html">Index 53</option>
  107.   <option value="index54.html">Index 54</option>
  108.   <option value="index55.html">Index 55</option>
  109.   <option value="index56.html">Index 56</option>
  110.   <option value="index57.html">Index 57</option>
  111.   <option value="index58.html">Index 58</option>
  112.   <option value="index59.html">Index 59</option>
  113.   <option value="index60.html">Index 60</option>
  114.   <option value="index61.html">Index 61</option>
  115.   <option value="index62.html">Index 62</option>
  116.   <option value="index63.html">Index 63</option>
  117.   <option value="index64.html">Index 64</option>
  118.   <option value="index65.html">Index 65</option>
  119.   <option value="index66.html">Index 66</option>
  120.   <option value="index67.html">Index 67</option>
  121.   <option value="index68.html">Index 68</option>
  122.   <option value="index69.html">Index 69</option>
  123.   <option value="index70.html">Index 70</option>
  124.   <option value="index71.html">Index 71</option>
  125.   <option value="index72.html">Index 72</option>
  126.   <option value="index73.html">Index 73</option>
  127.   <option value="index74.html">Index 74</option>
  128.   <option value="index75.html">Index 75</option>
  129.   <option value="index76.html">Index 76</option>
  130.   <option value="index77.html">Index 77</option>
  131.   <option value="index78.html">Index 78</option>
  132.   <option value="index79.html">Index 79</option>
  133.   <option value="index80.html">Index 80</option>
  134.   <option value="index81.html">Index 81</option>
  135.   <option value="index82.html">Index 82</option>
  136.   <option value="index83.html">Index 83</option>
  137.   <option value="index84.html">Index 84</option>
  138.   <option value="index85.html">Index 85</option>
  139.   <option value="index86.html">Index 86</option>
  140.   <option value="index87.html">Index 87</option>
  141.   <option value="index88.html">Index 88</option>
  142.   <option value="index89.html">Index 89</option>
  143.   <option value="index90.html">Index 90</option>
  144.   <option value="index91.html">Index 91</option>
  145.   <option value="index92.html">Index 92</option>
  146.   <option value="index93.html">Index 93</option>
  147.   <option value="index94.html">Index 94</option>
  148.   <option value="index95.html">Index 95</option>
  149.   <option value="index96.html">Index 96</option>
  150.   <option value="index97.html">Index 97</option>
  151.   <option value="index98.html">Index 98</option>
  152.   <option value="index99.html">Index 99</option>
  153.   <option value="index100.html">Index 100</option>
  154.   <option value="index101.html">Index 101</option>
  155.   <option value="index102.html">Index 102</option>
  156.   <option value="index103.html">Index 103</option>
  157.   <option value="index104.html">Index 104</option>
  158.   <option value="index105.html">Index 105</option>
  159.   <option value="index106.html">Index 106</option>
  160.   <option value="index107.html">Index 107</option>
  161.   <option value="index108.html">Index 108</option>
  162.   <option value="index109.html">Index 109</option>
  163.   <option value="index110.html">Index 110</option>
  164.   <option value="index111.html">Index 111</option>
  165.   <option value="index112.html">Index 112</option>
  166. </select></form>
  167. </td><!-- EndNavigationElement -->
  168.     <!-- BeginNavigationSubGroup --><td>
  169.       
  170.       <!-- BeginNavigationElement --> <span class="navigationtext">of&nbsp;112</span><!-- EndNavigationElement -->
  171.     </td><!-- EndNavigationSubGroup -->
  172.   </tr>
  173. </table>
  174. <!-- EndNavigationGroup -->
  175. </td>
  176.   </tr>
  177. </table>
  178. <!-- EndNavigationTop -->
  179. <!-- BeginTable -->
  180. <table width="100%">
  181.   <tr>
  182.     <td align="center">
  183. <table class="index_table" cellspacing="0">
  184.   <tr>
  185.     <td class="index_table_cell"><div class="thumbnail"><a href="images/0016.jpg" target="_blank"><img src="thumbnails/tn0016.jpg" alt="0016.jpg" title="0016.jpg" border="0" width="300" height="200" /></a></div><div class="thumbnail_title"><a href="images/0016.jpg" target="_blank" class="thumbnailtitle">0016</a></div>
  186. </td>
  187.     <td class="index_table_cell"><div class="thumbnail"><a href="images/0017.jpg" target="_blank"><img src="thumbnails/tn0017.jpg" alt="0017.jpg" title="0017.jpg" border="0" width="300" height="200" /></a></div><div class="thumbnail_title"><a href="images/0017.jpg" target="_blank" class="thumbnailtitle">0017</a></div>
  188. </td>
  189.     <td class="index_table_cell"><div class="thumbnail"><a href="images/0018.jpg" target="_blank"><img src="thumbnails/tn0018.jpg" alt="0018.jpg" title="0018.jpg" border="0" width="300" height="200" /></a></div><div class="thumbnail_title"><a href="images/0018.jpg" target="_blank" class="thumbnailtitle">0018</a></div>
  190. </td>
  191.     <td class="index_table_cell"><div class="thumbnail"><a href="images/0019_2.jpg" target="_blank"><img src="thumbnails/tn0019_2.jpg" alt="0019_2.jpg" title="0019_2.jpg" border="0" width="300" height="200" /></a></div><div class="thumbnail_title"><a href="images/0019_2.jpg" target="_blank" class="thumbnailtitle">0019_2</a></div>
  192. </td>
  193.   </tr>
  194.   <tr>
  195.     <td class="index_table_cell"><div class="thumbnail"><a href="images/002.jpg" target="_blank"><img src="thumbnails/tn002.jpg" alt="002.jpg" title="002.jpg" border="0" width="225" height="300" /></a></div><div class="thumbnail_title"><a href="images/002.jpg" target="_blank" class="thumbnailtitle">002</a></div>
  196. </td>
  197.     <td class="index_table_cell"><div class="thumbnail"><a href="images/0022.jpg" target="_blank"><img src="thumbnails/tn0022.jpg" alt="0022.jpg" title="0022.jpg" border="0" width="300" height="200" /></a></div><div class="thumbnail_title"><a href="images/0022.jpg" target="_blank" class="thumbnailtitle">0022</a></div>
  198. </td>
  199.     <td class="index_table_cell"><div class="thumbnail"><a href="images/0024.jpg" target="_blank"><img src="thumbnails/tn0024.jpg" alt="0024.jpg" title="0024.jpg" border="0" width="200" height="300" /></a></div><div class="thumbnail_title"><a href="images/0024.jpg" target="_blank" class="thumbnailtitle">0024</a></div>
  200. </td>
  201.     <td class="index_table_cell"><div class="thumbnail"><a href="images/0025.jpg" target="_blank"><img src="thumbnails/tn0025.jpg" alt="0025.jpg" title="0025.jpg" border="0" width="200" height="300" /></a></div><div class="thumbnail_title"><a href="images/0025.jpg" target="_blank" class="thumbnailtitle">0025</a></div>
  202. </td>
  203.   </tr>
  204.   <tr>
  205.     <td class="index_table_cell"><div class="thumbnail"><a href="images/003_2.jpg" target="_blank"><img src="thumbnails/tn003_2.jpg" alt="003_2.jpg" title="003_2.jpg" border="0" width="200" height="300" /></a></div><div class="thumbnail_title"><a href="images/003_2.jpg" target="_blank" class="thumbnailtitle">003_2</a></div>
  206. </td>
  207.     <td class="index_table_cell"><div class="thumbnail"><a href="images/0030.jpg" target="_blank"><img src="thumbnails/tn0030.jpg" alt="0030.jpg" title="0030.jpg" border="0" width="200" height="300" /></a></div><div class="thumbnail_title"><a href="images/0030.jpg" target="_blank" class="thumbnailtitle">0030</a></div>
  208. </td>
  209.     <td class="index_table_cell"><div class="thumbnail"><a href="images/0031.jpg" target="_blank"><img src="thumbnails/tn0031.jpg" alt="0031.jpg" title="0031.jpg" border="0" width="200" height="300" /></a></div><div class="thumbnail_title"><a href="images/0031.jpg" target="_blank" class="thumbnailtitle">0031</a></div>
  210. </td>
  211.     <td class="index_table_cell"><div class="thumbnail"><a href="images/0034_2.jpg" target="_blank"><img src="thumbnails/tn0034_2.jpg" alt="0034_2.jpg" title="0034_2.jpg" border="0" width="300" height="200" /></a></div><div class="thumbnail_title"><a href="images/0034_2.jpg" target="_blank" class="thumbnailtitle">0034_2</a></div>
  212. </td>
  213.   </tr>
  214.   <tr>
  215.     <td class="index_table_cell"><div class="thumbnail"><a href="images/0036.jpg" target="_blank"><img src="thumbnails/tn0036.jpg" alt="0036.jpg" title="0036.jpg" border="0" width="300" height="200" /></a></div><div class="thumbnail_title"><a href="images/0036.jpg" target="_blank" class="thumbnailtitle">0036</a></div>
  216. </td>
  217.     <td class="index_table_cell"><div class="thumbnail"><a href="images/004.jpg" target="_blank"><img src="thumbnails/tn004.jpg" alt="004.jpg" title="004.jpg" border="0" width="200" height="300" /></a></div><div class="thumbnail_title"><a href="images/004.jpg" target="_blank" class="thumbnailtitle">004</a></div>
  218. </td>
  219.     <td class="index_table_cell"><div class="thumbnail"><a href="images/004_2.jpg" target="_blank"><img src="thumbnails/tn004_2.jpg" alt="004_2.jpg" title="004_2.jpg" border="0" width="200" height="300" /></a></div><div class="thumbnail_title"><a href="images/004_2.jpg" target="_blank" class="thumbnailtitle">004_2</a></div>
  220. </td>
  221.     <td class="index_table_cell"><div class="thumbnail"><a href="images/0041.jpg" target="_blank"><img src="thumbnails/tn0041.jpg" alt="0041.jpg" title="0041.jpg" border="0" width="300" height="200" /></a></div><div class="thumbnail_title"><a href="images/0041.jpg" target="_blank" class="thumbnailtitle">0041</a></div>
  222. </td>
  223.   </tr>
  224.   <tr>
  225.     <td class="index_table_cell"><div class="thumbnail"><a href="images/005.jpg" target="_blank"><img src="thumbnails/tn005.jpg" alt="005.jpg" title="005.jpg" border="0" width="225" height="300" /></a></div><div class="thumbnail_title"><a href="images/005.jpg" target="_blank" class="thumbnailtitle">005</a></div>
  226. </td>
  227.     <td class="index_table_cell"><div class="thumbnail"><a href="images/005_3.jpg" target="_blank"><img src="thumbnails/tn005_3.jpg" alt="005_3.jpg" title="005_3.jpg" border="0" width="200" height="300" /></a></div><div class="thumbnail_title"><a href="images/005_3.jpg" target="_blank" class="thumbnailtitle">005_3</a></div>
  228. </td>
  229.     <td class="index_table_cell"><div class="thumbnail"><a href="images/005_4.jpg" target="_blank"><img src="thumbnails/tn005_4.jpg" alt="005_4.jpg" title="005_4.jpg" border="0" width="200" height="300" /></a></div><div class="thumbnail_title"><a href="images/005_4.jpg" target="_blank" class="thumbnailtitle">005_4</a></div>
  230. </td>
  231.     <td class="index_table_cell"><div class="thumbnail"><a href="images/006.jpg" target="_blank"><img src="thumbnails/tn006.jpg" alt="006.jpg" title="006.jpg" border="0" width="200" height="300" /></a></div><div class="thumbnail_title"><a href="images/006.jpg" target="_blank" class="thumbnailtitle">006</a></div>
  232. </td>
  233.   </tr>
  234. </table>
  235. </td>
  236.   </tr>
  237. </table>
  238. <!-- EndTable -->
  239. <p align="center"><br />
  240. <a href="http://www.digitaldutch.com/arles/" target="_top" style="font-size: 10pt;">Generated with Arles Image Web Page Creator</a></p>
  241. </body>
  242. </html>
复制代码

TOP

本帖最后由 apang 于 2015-5-5 18:27 编辑

以 UltraEdit32 为例
查找框输入:
(thumbnailtitle">).+?(</a)
替换框输入:
\1E023026\2
勾选 正则表达式(E):Perl
1

评分人数

TOP

返回列表