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

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

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?
1 Solution
Haven't tested this too much but seems to work


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

Open in new window

sasnaktivAuthor Commented:
Hey Gary,
It definitely does work!
Thank you.
Thank you.
Thank you!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

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