I need to do the following, and I can not find a suitable way to do it ...
This is the code of a function, which puts two tabulations (two spaces with \ t) when finding the first space inside the variable 'customText'.
function generatePageLinks(text, isChapter, pageId) {
//Variable auxiliar que captura el texto de la página de 'text'.
var aux = text;
var customText = aux.replace(" ", "\t\t");
var $element = $(document.createElement('td'));
var $link = $('<a class="hier-link"></a>').attr('href', '#').attr('data-page-id', pageId).text(customText);
$element.append('<div class="text-wrapper">');
$element.append($('<pre class="hier-move">').html(isChapter ? customText : $link));
return $element;
}
I need to improve this function, so that it applies two tabulations when there are 2 characters before the space, and a single tabulated in case there are 3 characters before space.
Is it viable? A thousand thanks in advance!