JSFiddle - React, Tailwind, and code Playground
JavaScript
var text = "It's nice in Amsterdam";
var cities = "(Berlin|Athens|Amsterdam|Buenos Aires|endless|list|from|extra|file)";
var cityRx = new RegExp("/.+ " + cities + "$/", "i");
var city = text.match( cityRx );
$("body").append( "Where ist nice? " + city + "!" );