?
Solved

String manipulation

Posted on 2005-03-11
3
Medium Priority
?
242 Views
Last Modified: 2006-11-17
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
Comment
Question by:lwinkenb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 32

Accepted Solution

by:
Batalf earned 1000 total points
ID: 13522255
$string = "HiMyNameIsStan";

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

echo $newString;
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 13522543
Thanks Batalf.  Can you tell me what the "\\1" means in that pattern?
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 13522619
nevermind, I read the preg_replace documentation, and figured it out.  Thanks for the help.
0

Featured Post

7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question