views:

42

answers:

1

HI,

I would like to create a function that beautify my text. For this I use a regex who remplace some characters, but it not run. Can you give me the regular expression for this :

  • Replace the first letter by a caps
  • Replace any underscore _ by a space

So for example: the_pack_2 will be The pack 2. Thx

+1  A: 

No need for regex here.

$foo = 'the_pack_2';
$foo = ucfirst($foo); // The_pack_2
$foo = str_replace("_", " ", $foo); // The pack 2
serg