I am trying to replace each letter div with the set "span".
This code works except for letters with accents like "รฉ". Can you help me?
$('h2').each(function(){ $(this).html($(this).text().replace(/(\w)/g, "<span>$&</span>")); });
You can try the following regular expression:
/([^\x00-\x80]|\w)/g
\w does not contain diacritical characters, so you need to specify a Unicode range, for example
\w
/[az\u00C0-\u00F6\u00F8-\017E]/gi
My option without regex
http://jsfiddle.net/d6pDG/
var html = $('.test').html(); var ret = ""; $.each(html.split(''), function(k, v) { ret += "<span>" + v + "</span>"; }); $('.test').html(ret);
Source: https://habr.com/ru/post/1489638/More articles:apache httpclient is the most efficient way to read the response - apache-httpclient-4.xJavaScript Regex Extension - javascriptPG: relationship error does not exist - ruby-on-railsGrails data binding: instantiating an abstract class - grailsTest for Android applications using selenium webdriver - androidCAKeyframeAnimation Manual Progress - ioshow to focus the next cell in a kendo grid by pressing the enter key - jquerydependency = [com.google.android.gms: google-play-services: apklib: 7: compilation] not found in workspace - androidhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1489642/alternatives-to-adobe-shadow&usg=ALkJrhiOllDe0fLs3mwuGEL9SB7uOVCBIwsoftInputMode in fragments - androidAll Articles