JSFiddle - React, Tailwind, and code Playground JavaScript var text = "1dozen 3 dozen dozen1 30/kg"; var regex = /(\d+)/g; alert(text.match(regex));