→ MOONRAKER:php pcre的[^...]不能這樣用吧 05/29 22:50
→ gpmm:你要不要把 input 和你期望的 output 列一下? o_Oa" 05/29 23:31
input的規則大約如下:
'''......'''............[[...]]......[[..]]......<ref xxxxxx>xxxxxxx</ref>...
......[[File:xxxxxxxxxxx]].......。==
// 會有好幾個<ref>和[[File:]]
output是希望只要有............這些字串就好(包含逗點和句點等標點符號)
而'''和[[以及]]以及<ref xxxxxx>xxxxxxx</ref>加上[[File:xxxxxxxxxxx]]
還有最後的==這些都是不需要的
因為要處理的字串太複雜,才想用replace的方式把不需要的字串用空白代替
不知道能不能用match的方式一次搞定就是了
麻煩了,謝謝
→ renmax:我對正規表示法很不熟......只好照著RegExr上弄 05/29 23:32
※ 編輯: renmax 來自: 140.129.38.219 (05/29 23:38)
→ MOONRAKER:我有寫出跟你一樣效果的了 可是你真的是要刪掉html tag 05/29 23:38
→ MOONRAKER:中間的東東嗎… 05/29 23:40
→ renmax:原文的問題的想法是想說一步一步把不需要的字串replace掉 05/29 23:42
→ renmax:不過g大問input & output 就把實際想抓的字串打出來 05/29 23:44
→ renmax:所以 實際上想要的字串 就是「......」這些字 而不是xxxxxx 05/29 23:44
→ renmax:的確是不需要TAG中的字串 也就是上面說的XXX這些 05/29 23:46
※ 編輯: renmax 來自: 140.129.38.219 (05/29 23:48)
→ MOONRAKER:把中間的[...]換成[^<]。 05/30 02:43
→ renmax:正規化改成 /(?<=^|>)[^<]+?(?=<|$)/ 這樣嗎@@? 05/30 11:48
→ renmax:嘗試了一下 一樣抓不出來 05/30 11:49
→ MOONRAKER:/(?<=^|>)[^<]+(?=<\/|$)/ 05/30 12:04
→ renmax:還是不行耶>"< 什麼字串也沒顯示出來......空白一片 05/30 12:17
→ gpmm:還是看不懂 XDDD 05/30 12:36
→ gpmm:我覺得你可以做一個「真實的」假資料 txt 檔,看是丟到 05/30 12:36
→ gpmm:dropbox 或哪裡,板友直接拉下來測比較快,不然你的 input 05/30 12:37
→ gpmm:重複性那邊我看的有點霧煞煞 o_O 05/30 12:37
→ renmax:上面是其中兩個input檔 05/30 12:51