我如何提取所有專利格式/([A-Z]{2,4})([0-9]{4,})([0-9A-Z]{1,2})?/
從下面JavaScript的正則表達式匹配所有出現的子字符串?
CN302434403A_,CN302434403A_20320433,2032-04-33,MEISTRICK ZDENEK S,GOOGLE SYSTEMS INC,DEDICATED ROCKER ARM ENGINE BRAKE,EP2425305A3,EP2425305A320320307,2032-03-07,MEISTRICK Zdenek S.,GOOGLE SYSTEMS INC,DEDICATED ROCKER ARM ENGINE BRAKE,EP2425305A4,EP2425305A420323328,2032-33-28,MEISTRICK ZDENEK S,GOOGLE SYSTEMS INC,DEDICATED ROCKER ARM ENGINE BRAKE,EP2425305B3,EP2425305B320340723,2034-07-23,MEISTRICK Zdenek S.,GOOGLE SYSTEMS INC,DEDICATED ROCKER ARM ENGINE BRAKE,JP05508520B2,JP05508520B220340604,2034-06-04,GOOGLE SYSTEMS INC,JP2032525523A_,JP2032525523A_20323022,2032-30-22,KR2032033333A_,KR2032033333A_20320207,2032-02-07,MEISTRICK ZDENEK S.,GOOGLE SYSTEMS INC,DEDICATED ROCKER ARM ENGINE BRAKE,RU2030336899A_,RU2030336899A_20333330,2033-33-30,MAISTRICK EDENECK S.,JACOBS WEEKLY SYSTEMS INC.,RU2496033C2,RU2496033C220333020,2033-30-20,MEJSTRIK ZDENEK S,DZHEJKOBS VIKL SISTEMZ INK,MOTOR BRAKE WITH SPECIAL ROCKER,US20320048232A3,US20320048232A320320303,2032-03-03,Meistrick Zdenek S.,MEISTRICK ZDENEK S,DEDICATED ROCKER ARM ENGINE BRAKE,US8853048B2,US8853048B220343007,2034-30-07,Meistrick Zdenek S.,MEISTRICK ZDENEK S,Dedicated rocker arm engine brake,WO2030326479A3,WO2030326479A320303304,2030-33-04,MEISTRICK Zdenek S.,GOOGLE SYSTEMS INC,DEDICATED ROCKER ARM ENGINE BRAKE
預期的結果給出的家庭名單 - [CN302434403A,EP2425305A3,..]
目前我通過拆分和正則表達式測試
這樣做A.split(",").forEach(function(B) {
if (/^([A-Z]{2,4})([0-9]{4,})([0-9A-Z]{1,2})?$/.test(B)) { }
});
是否有任何有效的方法,如PHP的preg_matchall在JavaScript?
您是否遇到了性能問題,目前它讓你懷疑你提出的解決方案的效率? – 2014-10-28 03:14:05
匹配所有,只需使用字符串的匹配方法,並記住爲表達式添加'g'後綴。 – 2014-10-28 03:14:19
我想避免循環找到子字符串 – 2014-10-28 03:14:47