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

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -