亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
12下一頁
最近訪問板塊 發(fā)新帖
查看: 5750 | 回復: 19
打印 上一主題 下一主題

[文本處理] 如何匹配這個表達式? [復制鏈接]

論壇徽章:
2
獅子座
日期:2014-05-30 21:43:03巳蛇
日期:2014-05-30 21:46:14
跳轉到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2014-05-30 13:10 |只看該作者 |倒序瀏覽
20可用積分
本帖最后由 tgwz88 于 2014-05-30 14:21 編輯

<div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">

我想把上面這個字符串匹配出來,通過sed s///g 或者awk的gsub 進行替換。
可我怎么也匹配不出來,有什么好方法嗎?

詳情可參見9樓

最佳答案

查看完整內容

回復 14# tgwz88 其實用sed就可以了,這樣在時間后面加#會容易點。

論壇徽章:
780
金牛座
日期:2014-02-26 17:49:58水瓶座
日期:2014-02-26 18:10:15白羊座
日期:2014-04-15 19:29:52寅虎
日期:2014-04-17 19:43:21酉雞
日期:2014-04-19 21:24:10子鼠
日期:2014-04-22 13:55:24卯兔
日期:2014-04-22 14:20:58亥豬
日期:2014-04-22 16:13:09獅子座
日期:2014-05-05 22:31:17摩羯座
日期:2014-05-06 10:32:53處女座
日期:2014-05-12 09:23:11子鼠
日期:2014-05-21 18:21:27
2 [報告]
發(fā)表于 2014-05-30 13:10 |只看該作者
回復 14# tgwz88
其實用sed就可以了,這樣在時間后面加#會容易點。
  1. sed -r 's/<[^>]*>//g;s/\s*&nbsp;\s*/\n/g;s/\n+/\n/g;s/\n[0-9]{2}:[0-9]{2}/&#/g' i
  2. May 30, 2014
  3. 05:00#Russia political and economic calendar: May 30
  4. May 29, 2014
  5. 23:09#Poroshenko discusses help to Ukraine with EBRD chief - statement
  6. 22:50#Donetsk militia sends 34 Russian volunteers' bodies to Russia - leader
  7. 22:39#Abkhazia parliament fires PM, urges president to go
  8. 22:16#EEU to be economically, politically attractive for some states - Federation Council (Part 2)
  9. 22:05#Abkhazia parliament to consider dismissal of president - opposition leader
  10. 21:57#Abkhaz opposition ready to discuss all issues related to Ankvab's safety if he resigns voluntarily
  11. 21:57#Arms depot destroyed in attack on Ukraine National Guard base - statement
  12. 21:56#Abkhazia leader denies he is stepping down
  13. 21:56#EEU to be economically, politically attractive for some states - Federation Council
  14. 21:40#ABKHAZ OPPOSITION READY TO DISCUSS ALL ISSUES RELATED TO ANKVAB'S SAFETY IN CASE HE RESIGNS VOLUNTARILY - ABKHAZ NATIONAL COUNCIL MEMBER SHAMBA
  15. 21:37#Businessman shot dead in center of Moscow
  16. 21:36#ABKHAZ PRESIDENT ANKVAB SAYS THAT RUMORS ON HIS RESIGNATION ARE NOT TRUE AND THAT HE CONTINUES CARRYING OUT PRESIDENTIAL DUTIES
  17. 21:12#Abkhaz opposition passes memorandum demanding reforms, "unconditional legal order"
  18. 21:10#Fighting under way in Luhansk region's Aleksandrovsk - Ukrainian army (Part 2)
  19. 20:47#Protestors in central Kharkiv demand Kyiv authorities stop bloodshed
  20. 20:46#Poroshenko, CoE secretary general discuss investigating Maidan, Odessa events
  21. 20:41#Pro-Kyiv volunteers says are forming special battalion
  22. 20:07#Ukraine receives $750 million from World Bank
  23. 20:05#Soldier dies as army truck attacked in east Ukraine - source
  24. 19:58#Dollar, euro gain as Ukraine situation keeps ruble under pressure
  25. 19:52#Main indexes of the Russia stock market for May 29
  26. 19:51#Potanin disposes of 0.1% direct stake in Norilsk Nickel (Part 2)
  27. 19:41#Sisi victory in Egypt presidential poll means closer ties with Russia - lawmaker
  28. 19:39#Donetsk militia detain suspected looters
  29. 19:37#Police arrest suspected rapist, robber operating in Moscow since 1987 - RIC (Part 2)
  30. 19:35#First talks between govt, opposition reps take place in Sukhumi
  31. 19:34#Sibur plans to bid for 17.5% stake in Polief
  32. 19:30#Potanin disposes of 0.1% direct stake in Norilsk Nickel
  33. 19:27#Russian stock market ends Thursday up, unaffected by weak U.S. GDP statistics
  34. Select page:
  35. 1
  36. 2
  37. 3
  38. 4
  39. Next
復制代碼

論壇徽章:
16
IT運維版塊每日發(fā)帖之星
日期:2015-08-24 06:20:00綜合交流區(qū)版塊每日發(fā)帖之星
日期:2015-10-14 06:20:00IT運維版塊每日發(fā)帖之星
日期:2015-10-25 06:20:00IT運維版塊每日發(fā)帖之星
日期:2015-11-06 06:20:00IT運維版塊每日發(fā)帖之星
日期:2015-12-10 06:20:00平安夜徽章
日期:2015-12-26 00:06:302016猴年福章徽章
日期:2016-02-18 15:30:34IT運維版塊每日發(fā)帖之星
日期:2016-04-15 06:20:00IT運維版塊每日發(fā)帖之星
日期:2016-05-21 06:20:00綜合交流區(qū)版塊每日發(fā)帖之星
日期:2016-08-16 06:20:002015七夕節(jié)徽章
日期:2015-08-21 11:06:17IT運維版塊每日發(fā)帖之星
日期:2015-08-14 06:20:00
3 [報告]
發(fā)表于 2014-05-30 13:13 |只看該作者
40px/20px這2個數(shù)字么?
regexp好難啊感覺。

grep -o 可以么

論壇徽章:
16
IT運維版塊每日發(fā)帖之星
日期:2015-08-24 06:20:00綜合交流區(qū)版塊每日發(fā)帖之星
日期:2015-10-14 06:20:00IT運維版塊每日發(fā)帖之星
日期:2015-10-25 06:20:00IT運維版塊每日發(fā)帖之星
日期:2015-11-06 06:20:00IT運維版塊每日發(fā)帖之星
日期:2015-12-10 06:20:00平安夜徽章
日期:2015-12-26 00:06:302016猴年福章徽章
日期:2016-02-18 15:30:34IT運維版塊每日發(fā)帖之星
日期:2016-04-15 06:20:00IT運維版塊每日發(fā)帖之星
日期:2016-05-21 06:20:00綜合交流區(qū)版塊每日發(fā)帖之星
日期:2016-08-16 06:20:002015七夕節(jié)徽章
日期:2015-08-21 11:06:17IT運維版塊每日發(fā)帖之星
日期:2015-08-14 06:20:00
4 [報告]
發(fā)表于 2014-05-30 13:14 |只看該作者
哦字符串啊
[^<[^>]+>]
這個呢?

論壇徽章:
16
IT運維版塊每日發(fā)帖之星
日期:2015-08-24 06:20:00綜合交流區(qū)版塊每日發(fā)帖之星
日期:2015-10-14 06:20:00IT運維版塊每日發(fā)帖之星
日期:2015-10-25 06:20:00IT運維版塊每日發(fā)帖之星
日期:2015-11-06 06:20:00IT運維版塊每日發(fā)帖之星
日期:2015-12-10 06:20:00平安夜徽章
日期:2015-12-26 00:06:302016猴年福章徽章
日期:2016-02-18 15:30:34IT運維版塊每日發(fā)帖之星
日期:2016-04-15 06:20:00IT運維版塊每日發(fā)帖之星
日期:2016-05-21 06:20:00綜合交流區(qū)版塊每日發(fā)帖之星
日期:2016-08-16 06:20:002015七夕節(jié)徽章
日期:2015-08-21 11:06:17IT運維版塊每日發(fā)帖之星
日期:2015-08-14 06:20:00
5 [報告]
發(fā)表于 2014-05-30 13:19 |只看該作者
這樣就好了吧
"^>[^>]+>$"

以^開頭,中間若干個非>的字符,最后>結尾。

論壇徽章:
16
IT運維版塊每日發(fā)帖之星
日期:2015-08-24 06:20:00綜合交流區(qū)版塊每日發(fā)帖之星
日期:2015-10-14 06:20:00IT運維版塊每日發(fā)帖之星
日期:2015-10-25 06:20:00IT運維版塊每日發(fā)帖之星
日期:2015-11-06 06:20:00IT運維版塊每日發(fā)帖之星
日期:2015-12-10 06:20:00平安夜徽章
日期:2015-12-26 00:06:302016猴年福章徽章
日期:2016-02-18 15:30:34IT運維版塊每日發(fā)帖之星
日期:2016-04-15 06:20:00IT運維版塊每日發(fā)帖之星
日期:2016-05-21 06:20:00綜合交流區(qū)版塊每日發(fā)帖之星
日期:2016-08-16 06:20:002015七夕節(jié)徽章
日期:2015-08-21 11:06:17IT運維版塊每日發(fā)帖之星
日期:2015-08-14 06:20:00
6 [報告]
發(fā)表于 2014-05-30 13:28 |只看該作者
此外,真要替換的話,regexp的greedy match不就行了嗎

<.*> 會匹配最多的,不知道你的目的是,難道又是X-Y problem ?

論壇徽章:
2
獅子座
日期:2014-05-30 21:43:03巳蛇
日期:2014-05-30 21:46:14
7 [報告]
發(fā)表于 2014-05-30 13:33 |只看該作者
回復 4# expert1


    謝謝,可一行文本中有N個這樣相同的字符串……,而且這些字符串相鄰之間包含如下字符:
data</div><div style=''><a style=''>data

論壇徽章:
780
金牛座
日期:2014-02-26 17:49:58水瓶座
日期:2014-02-26 18:10:15白羊座
日期:2014-04-15 19:29:52寅虎
日期:2014-04-17 19:43:21酉雞
日期:2014-04-19 21:24:10子鼠
日期:2014-04-22 13:55:24卯兔
日期:2014-04-22 14:20:58亥豬
日期:2014-04-22 16:13:09獅子座
日期:2014-05-05 22:31:17摩羯座
日期:2014-05-06 10:32:53處女座
日期:2014-05-12 09:23:11子鼠
日期:2014-05-21 18:21:27
8 [報告]
發(fā)表于 2014-05-30 13:33 |只看該作者
回復 1# tgwz88
沒看懂題目,是從很大的一個html文件中找出類似
  1. <div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">
復制代碼
的片段?

論壇徽章:
780
金牛座
日期:2014-02-26 17:49:58水瓶座
日期:2014-02-26 18:10:15白羊座
日期:2014-04-15 19:29:52寅虎
日期:2014-04-17 19:43:21酉雞
日期:2014-04-19 21:24:10子鼠
日期:2014-04-22 13:55:24卯兔
日期:2014-04-22 14:20:58亥豬
日期:2014-04-22 16:13:09獅子座
日期:2014-05-05 22:31:17摩羯座
日期:2014-05-06 10:32:53處女座
日期:2014-05-12 09:23:11子鼠
日期:2014-05-21 18:21:27
9 [報告]
發(fā)表于 2014-05-30 13:35 |只看該作者
回復 6# tgwz88
能提供一下類似的原始文本數(shù)據(jù)嗎?

   

論壇徽章:
2
獅子座
日期:2014-05-30 21:43:03巳蛇
日期:2014-05-30 21:46:14
10 [報告]
發(fā)表于 2014-05-30 13:38 |只看該作者
本帖最后由 tgwz88 于 2014-05-30 20:36 編輯

回復 8# Herowinter

我想根據(jù)數(shù)據(jù)得到如下內容:
May 30, 2014
09:56#Luhansk militia detains 4 Europeans, presumably from OSCE (Part 3)
………等等………


數(shù)據(jù)如下:
<div style="width: 140px; float: left; height: 20px;"><b style='color: #536570;'>May 30, 2014</b></div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:56</div><div style=''><a href=/newsinf.asp?id=509761 style=''>Luhansk militia detains 4 Europeans, presumably from OSCE (Part 3)</a></div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;color:red;">09:50</div><div style='color:red'>RIGHT SECTOR MILITANTS SUSPECTED OF PLOTTING TERROR ACTS DETAINED IN CRIMEA - RUSSIA'S FSB</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:48</div><div style=''>OSCE Minsk Group co-chairs to hold meetings in Baku</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:41</div><div style=''>TGK-2 negotiating sale of plants with Spring, joint projects with Chinese cos</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:41</div><div style=''>Luhansk militia detains 4 Europeans, presumably from OSCE (Part 2)</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:39</div><div style=''>Abkhaz president reiterates he will not resign or dismiss prime minister</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:37</div><div style=''>Lukoil boosts oil production 1.9% in Q1 to 22.5 mln tonnes, production in West Siberia falls 2.8%</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:34</div><div style=''>Retail lending growth in Russia has slowed to "acceptable" 25-30% - CBR</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:31</div><div style=''>Luhansk militia detains 4 Europeans, presumably from OSCE</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:31</div><div style=''>RusHydro investment program without subsidiaries might exceed plan by 25% in 2015-2017</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:30</div><div style=''>Banks have 1020.8 bln rbs on CBR correspondent accounts on May 30.</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:28</div><div style=''><a href=/newsinf.asp?id=509750 style=''>CBR to auction up to 1.2 trln rubles in 3-month loans backed by nonmarket assets June 9, July 14</a></div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:25</div><div style=''>Luhansk militiamen claim to have "disarmed" Ukraine military unit</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:21</div><div style=''>Moscow press review for May 30, 2014</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:20</div><div style=''>Moscow press review for May 30, 2014</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:20</div><div style=''>Moscow press review for May 30, 2014</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:19</div><div style=''>Moscow press review for May 30, 2014</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:17</div><div style=''>Ankvab's refusal to resign a "silly attempt to cling to power" - Abkhaz opposition</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:13</div><div style=''>7 children injured in Ukraine's Donetsk region fighting between May 9 and May 28</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">09:00</div><div style=''>RUSSIA AND FSU GENERAL NEWS</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">08:35</div><div style=''>Results of forex trading on Moscow Exchange on May 29</div><div style="float: none; clear: left;">&nbsp;</div><div class=nws_date style="width: 40px; float: left; height: 20px;;">05:00</div><div style=''><a href=/newsinf.asp?id=509740 style=''>Russia political and economic calendar: May 30</a></div><div style="float: none; clear: left;">&nbsp;</div>
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術有限公司. 版權所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關心和支持過ChinaUnix的朋友們 轉載本站內容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP