Solved

partial decapitalize

Posted on 2007-11-13
5
512 Views
Last Modified: 2008-02-01
decapitalize non first letters:
eg. HI GUYS. HOW ARE       YOU -> Hi Guys. How Are       You
spacing "\t\r\n " should remain same

could do it myself, rushing to sleep
0
Comment
Question by:ed987
5 Comments
 
LVL 28

Expert Comment

by:gamebits
ID: 20277002
$string = "HI GUYS. HOW ARE       YOU ";

$string = ucfirst(strtolower($string));

print $string;
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20277003
$bar = "HI GUYS. HOW ARE YOU";
$bar = ucwords(strtolower($bar));
echo $bar;

hope this helps.
0
 
LVL 17

Expert Comment

by:nplib
ID: 20277007
$str = "HI GUYS. HOW ARE YOU";

$str = strtolower($str);

$str = ucwords($str);

echo $str;

//Output will be "Hi Guys. How Are You"
0
 
LVL 7

Author Comment

by:ed987
ID: 20277029
i asked for partial decapitalize, not partial capitalize
lowercase remains lowercase
HELLO guys - > Hello guys

0
 
LVL 20

Accepted Solution

by:
steelseth12 earned 500 total points
ID: 20277068
Hmmmm ....
try this

$str = "HELLO guys. HOW ARE";


$str = preg_replace("/([A-Z]+)/e","ucwords(strtolower('\\1'))",$str);

print $str;
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to dynamically set the form action using jQuery.

816 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

10 Experts available now in Live!

Get 1:1 Help Now