看板 RegExp 關於我們 聯絡資訊
Regex: \[\d+,"[^"]*(?<!US|CN)"[^\n]+\n ※ 引述《no1kk (心中在下雨)》之銘言: : 文件內容如下 : [ : [707860,"UA","Hurzuf"], : [519188,"RU","Novinki"], : [1283378,"NP","Gorkhā"], : [1270260,"IN","State of Haryāna"], : [708546,"UA","Holubynka"], : [1283710,"NP","Bāgmatī Zone"], : [529334,"RU","Mar’ina Roshcha"], : [1269750,"IN","Republic of India"], : [1283240,"NP","Kathmandu"], : [703363,"UA","Laspi"], : [3632308,"VE","Merida"], : [473537,"RU","Vinogradovo"], : [384848,"IQ","Qarah Gawl al ‘Ulyā"], : [569143,"RU","Cherkizovo"], : [713514,"UA","Alupka"], : [2878044,"DE","Lichtenrade"], : ... : 這是一個包含 城市id、國家、城市名稱 的 json 檔 : 因為我現在只想要某些特定國家的城市就好 : 要把不用的部分都刪掉 : 假設我想留下的是 US & CN : 我使用 notepad++ 的搜尋取代功能 - 規則運算式 : 搜尋: : .+"(?<!US|CN)",.+\n : 取代: : 但這只會找出國家欄位是空白的行 : 如 [6255149,"","North America"], : 無法找出國家非 US or CN 的行 : 請問我應該怎麼下條件呢? : 感謝!! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.246.56.126 ※ 文章網址: https://www.ptt.cc/bbs/RegExp/M.1521467133.A.01A.html
goldie: 高手推!lookahead/lookbehind各家實作都不太一樣,難以掌握 03/20 00:33
no1kk: 感謝你,成功了!!! 03/20 11:28