Solved

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

Posted on 2013-06-30
2
363 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
Comment Utility
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
Comment Utility
Hey Gary,
It definitely does work!
Thank you.
Thank you.
Thank you!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now