Solved

Is there a "preg replace" or something similar that will insert spaces between lc letters & uc letters?

Posted on 2013-06-30
2
366 Views
Last Modified: 2013-06-30
Hi Guys,
An external database that I have no access or control of is returning proper names in the following format "FirstLast" instead of "First Last".
I need to put a space between the First and Last names without losing the initial caps.
I think there may be a "preg_replace" type of solution for this problem but I don't know what it is. Can you help?
Thanks,
Sas
0
Comment
Question by:sasnaktiv
2 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39288632
Haven't tested this too much but seems to work

<?php
$name="FirstLast";

echo preg_replace('/([a-z])([A-Z])/', "$1 $2", $name);

Open in new window

0
 
LVL 1

Author Closing Comment

by:sasnaktiv
ID: 39288937
Hey Gary,
It definitely does work!
Thank you.
Thank you.
Thank you!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to dynamically set the form action using jQuery.
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.

803 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