admin管理员组文章数量:1337125
my string data as as follow.
var HmtlStr = "<span>My names is <u>KERBEROS</u>. AGE: 29, my eyes <b>BROWN</b>.</span"
result must be like this which i want;
<span>My names is <u>Kerberos</u>. Age: 29, my eyes <b>Brown</b>.</span
thank you very much for your help, already now.
my string data as as follow.
var HmtlStr = "<span>My names is <u>KERBEROS</u>. AGE: 29, my eyes <b>BROWN</b>.</span"
result must be like this which i want;
<span>My names is <u>Kerberos</u>. Age: 29, my eyes <b>Brown</b>.</span
thank you very much for your help, already now.
Share asked Oct 29, 2010 at 22:27 KerberosKerberos 1,2566 gold badges25 silver badges50 bronze badges3 Answers
Reset to default 5Perhaps the CSS text-transform: capitalize would work?
Use a function in a replace to change the strings:
HmtlStr = HmtlStr.replace(
/([A-Z])([A-Z]+)/g,
function(a,m1,m2) {
return m1 + m2.toLowerCase();
}
);
Edit:
The built in toLowerCase
method handles most characters, you just have to include them in the set in the regular expression ([A-ZÖİŞÜĞÇ]
) so that they are handled. To handle the few characters that the built in method doesn't cope with, you can make a function that replaces those first:
function localLowerCase(str) {
str = str.replace(
/İ/g,
function(m){
var i = "İ".indexOf(m);
return i != -1 ? "ı"[i] : m;
}
);
return str.toLowerCase();
}
You can easily add more characters for the function to handle by adding them in the /İ/
pattern, the "İ"
string and the replacement in the "ı"
string.
Try this one:
'apple cat dog stack overflow'.replace(/(\b)([a-zA-Z])/g,
function(firstLetter){
return firstLetter.toUpperCase();
})
:)
本文标签: javascriptfirst letter up all uppercase words in string data with jqueryStack Overflow
版权声明:本文标题:javascript - first letter up all uppercase words in string data with jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742402748a2468212.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论