PDA

View Full Version : RegExp to turn "someString" into "some String"?



jlizarraga
05-13-2009, 11:43 PM
Hi all,

I'm looking for a RegExp that I can use to transform a string like the one in the topic title.

I need to search for a lowercase character followed by an uppercase character, then insert a space between those two characters.

Any tips greatly appreciated! I am still very green when it comes to regexps.

Nile
05-14-2009, 12:04 AM
I don't understand why you wouldn't use PHP in a case like this... I really don't think JS is necessary.

jlizarraga
05-14-2009, 06:20 PM
Well this is for something that is AJAX driven. I'm dealing with strings that come back as part of a JSON object from a web service. This in particular is for the heading of a Javascript pop-up window, so I don't think I would be able to use PHP here.

clueful
05-15-2009, 12:57 PM
Well this is for something that is AJAX driven. I'm dealing with strings that come back as part of a JSON object from a web service. This in particular is for the heading of a Javascript pop-up window, so I don't think I would be able to use PHP here.

str = str.replace(/([a-z])([A-Z])/g, "$1 $2");