JSFiddle - React, Tailwind, and code Playground JavaScript var string = "x y\nx1 y1\nx2 y2"; var array = string.match(/[^\s]+/g);