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();
})
:)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742402748a4437239.html
评论列表(0条)