Solved

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

Posted on 2013-06-30
2
368 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
[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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

739 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