JSFiddle - React, Tailwind, and code Playground

HTML

<p>Hi سلام بر this این text can be برای اولین.</p>

<p> No XSS please &lt;br/&gt; </p>

CSS

.english {
    color: red;
}

.persian {
    color: blue;   
}
}

JavaScript

jQuery(function($) {
    $("p").each(function(){
        this.innerHTML = $(this).text().replace(/\S+/g, function (word) {
            var span = document.createElement("span");
            span.className = "word ";
            span.className += isEnglish(word) ? 'english' : '';
            span.className += isPersian(word) ? 'persian' : '';
            span.appendChild(document.createTextNode(word));
            return span.outerHTML;
        });
    });
    
    function isEnglish(word){
      return word.charCodeAt(0) < 255;
    }
    
    function isPersian(word){
      return word.charCodeAt(0) > 255;
    }
});