javascript regex match all occurrences of substring? -
how extract patent nos of format /([a-z]{2,4})([0-9]{4,})([0-9a-z]{1,2})?/
family list given below
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 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
expected result - [cn302434403a, ep2425305a3, ..]
currently doing splitting , regex test
a.split(",").foreach(function(b) { if (/^([a-z]{2,4})([0-9]{4,})([0-9a-z]{1,2})?$/.test(b)) { } });
is there efficient method php's preg_matchall in javascript ?
if after list of patent numbers, can not run regex , remove duplicates?
class="snippet-code-js lang-js prettyprint-override"> var str = "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 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"; var res = str.match(/([a-z]{2,4})([0-9]{4,})([0-9a-z]{1,2})/gi).filter(function(value, index, self) { homecoming self.indexof(value) === index; }); document.getelementbyid("demo").innerhtml = res;
class="snippet-code-html lang-html prettyprint-override"><!doctype html> <html> <body> <div id="demo"></div> </body>
javascript regex
No comments:
Post a Comment