JSFiddle - React, Tailwind, and code Playground by fkling January 14, 2011 JavaScript Y = "foo bars baz"; X = "bar"; alert(Y.substring(0, Y.indexOf(X) + X.length))