using Regex to match something from left -
train london boston - match train boston london train cardif london bus london paris - match
how can match if london appear before other cities regex? can string matching loop in javascript think regex better.
get lines includes london to
var str = `train london boston - match train boston london train cardif london bus london paris - match`, city = 'london'; console.log( str.match(new regexp('^.*\\b' + city + '\\sto\\b.*$', 'gmi')) )
Comments
Post a Comment