JSFiddle - React, Tailwind, and code Playground

HTML

<pre id="out"></pre>

JavaScript

function foo(str) {
  return str.replace(/\s/g, '').match(/(\D|[\d.]+)/g);
}




// test
const control = ['5 ', '/', '(', '2', '-', '  3', ')', '*', ' 1.333333 ', '+ ', '-', '11 '];
const str = '5 /(2-  3)* 1.333333 + -11 ';
out.textContent = control.join('|') + '\n' + foo(str).join('|');