JSFiddle - React, Tailwind, and code Playground
by paska
HTML
<h2>One-line list</h2><p>1234 ,5678, 9012 , 3456 7890</p>
<h2>Multiline list</h2><p>1234<br/>
5678<br/>
9012<br/>
3456<br/>
7890</p>
<input type="text" />
JavaScript
jQuery("input").bind("paste", function() {
var element = jQuery(this);
setTimeout(function () {
var text = element.val(),
matches = text.match(/[^0-9]+/g);
if (matches != null) {
for (var i = 0; i < matches.length; i++) {
text = text.replace(matches[i], ((matches[i].indexOf("-") < 0) ? "," : "-"));
}
element.val(text);
}
}, 100);
});