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 - Feed FileReader from server side files -

How to Change swipe Tab Title color in java Android -

Using globs in Perl replace one liner in TCL script -