/    Sign up×
Community /Pin to ProfileBookmark

Javascript function that converts to lower case

I want to write a javascript that converts the (each) first character occuring after space in a string to lower case e.g abc def ghi jkl to abc Def Ghi Jkl
Please help

I have tried document.getElementByID and then checking for spaqce by putting the element in the Array but it does not work. Kindly help

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@FangNov 29.2010 — [CODE]var re=/( [a-z])/g;
var out = 'abc def ghi jkl'.replace(re, function(){return RegExp.$1.toUpperCase()});
[/CODE]
Copy linkTweet thisAlerts:
@KorNov 29.2010 — About Regular Expressions:

http://lawrence.ecorp.net/inet/samples/regexp-intro.php

About usig RegExp to capitalize every word in a string:

http://lawrence.ecorp.net/inet/samples/regexp-format.php#cap
Copy linkTweet thisAlerts:
@mr_ab18authorNov 30.2010 — The function is not working. I have written a function but it iis not workling, I assume that error is "documentType[j]".

for(var i = 0; i < documentType.length; i++){
var ch = documentType.charAt(i);
if(ch == ' '){
var j = i + 1;
var ch = documentType.charAt(j);
documentType[j] = ch.toLowerCase();
}


Please tell me what to do ?
Copy linkTweet thisAlerts:
@FangNov 30.2010 — I want to write a javascript that converts the (each) first character occuring after space in a string to lower case e.g abc def ghi jkl to abc Def Ghi Jkl[/QUOTE]
Your example "abc def ghi jkl to abc Def Ghi Jkl" is to upper case, yet you use toLowerCase ?
×

Success!

Help @mr_ab18 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...