Address interception provincial cities and counties (regular expressions)

var add1 = 'Pegasus Sichuan Province town of Dujiangyan City, 34';
var ADD2 = 'Dongcheng District, Beijing, Qianmen Street, 1'
var ADD3 = 'Urumqi, Xinjiang Tianshan District, Zhongshan Road 479';
var ADD4 = 'Shuangliu County, Chengdu, Sichuan happy community No. 23';
var ADD5 = 'Tsim Sha Tsui, Hong Kong SAR and Western Road';
var REG = /.+ (province | City | autonomous | autonomous Prefecture | county | zone) /?;

console.log(add1 + ': ', add1.match(reg));
console.log(add2 + ': ', add2.match(reg));
console.log(add3 + ': ', add3.match(reg));
console.log(add4 + ': ', add4.match(reg));
console.log(add5 + ': ', add5.match(reg));

Guess you like

Origin www.cnblogs.com/hinux/p/11022086.html