Regex to match repeated patter after a string -
i need regex extract pattern after specific word (her limits::)
i have teststring ,so let's text between delimiter !limits::****! :
*ksjfl kfj sdfasdfaf dfasf asd sdf dfasd fdaf ad f afdfaf dfad bla bla ksfajs ldsfskj !limits::wlo1/whi1/whi1/whi1,wlo2/whi2/whi/whi2,.hier repeated pattern..,wlon/whin/clon/chin! fasdfakl skdfkas sflas fasf sdf afasf
i want words :
- wlo1
- whi1
- whi1
- whi1
- wlo2
- whi2
- whi
- whi2
- .
- .
- .
- wlon
- whin
- clon
- chin
i have tested (?:!\w+::(?:(\w+)/(\w+)/(\w+)/(\w+)))|(?:,(\w+)/(\w+)/(\w+)/(\w+))+.*!, fail
regular expressions:
/(w.*|c.*)(?=\/|!|,)/g
: match words beginning w
or c
followed /
, !
, or ,
/\/|,.*(?=,)|,/
: remove /
or ,
or characters followed ,
or ,
string returned first regexp
var str = "*ksjfl kfj sdfasdfaf dfasf asd sdf dfasd fdaf ad f afdfaf dfad bla bla ksfajs ldsfskj !limits::wlo1/whi1/whi1/whi1,wlo2/whi2/whi/whi2,.hier repeated pattern..,wlon/whin/clon/chin! fasdfakl skdfkas sflas fasf sdf afasf"; var res = str.match(/(w.*|c.*)(?=\/|!|,)/g)[0].split(/\/|,.*(?=,)|,/); document.body.textcontent = res.join(" ")
Comments
Post a Comment