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 的行
: 请问我应该怎么下条件呢?
: 感谢!!