JSFiddle - React, Tailwind, and code Playground
by petroveg
HTML
<span class="cena">102000000руб.</span>
<br>
<span class="cena">6780070 руб.</span>
<br>
<span class="cena">6780070</span>
JavaScript
$(function () {
$('.cena').each(function () {
$(this).text($(this).text().replace(/^\s*(\d+)(\d{3})\s*([а-я\.]+)?\s*$/, '$1 $2 $3'));
});
});