Re: how to add a space using a regex



"Jerry Preston" <g-preston1@xxxxxx> wrote:

> What I want to do is add a space between one's name when the are like
> the following:
>
> $name1 = "FirstLast:";
>
> I want change $name1 = "First Last";
>
> and
>
> $name1 = "FirstMiddleLast:";
>
> I want change $name1 = "First Middle Last";
>
> To be able to add spaces for either "FirstLast:" or "FirstMiddleLast:"
> with the same regex?

s/([a-z])([A-Z])/$1 $2/g;

(Wonders about Old McDonald)

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

.