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'))  )

regex explanation here

regular expression visualization


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -