• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

String manipulation

What I want to do is Add a space before all capital letters (Except for the first one).

So the string "HiMyNameIsStan"  would be "Hi My Name Is Stan".
0
lwinkenb
Asked:
lwinkenb
  • 2
1 Solution
 
BatalfCommented:
$string = "HiMyNameIsStan";

$newString = trim(preg_replace("/([A-Z])/"," \\1",$string));

echo $newString;
0
 
lwinkenbAuthor Commented:
Thanks Batalf.  Can you tell me what the "\\1" means in that pattern?
0
 
lwinkenbAuthor Commented:
nevermind, I read the preg_replace documentation, and figured it out.  Thanks for the help.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now