Topic awaiting preservation: regex - capitalize what's inside parenthesis (Page 1 of 1) |
|
---|---|
Paranoid (IV) Inmate From: 127.0.0.1 |
posted 08-31-2006 21:52
Greets! code: echo ucwords(strtolower($pageTITLE));
|
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 09-01-2006 13:32
code: preg_replace_callback ( "~\([^ A-Z)]+\)", my_func, $str, FUNNY_MATCH__FLAG_LOOK_IT_UP ); my_func ( $matches ) { return uppercase $matches[0]; } |
Paranoid (IV) Inmate From: 127.0.0.1 |
posted 09-26-2006 20:07
Alright - I was noodling with this finally, and I'm still having a problem with it. If I try code: <?php $str = "cool stuff (blah)"; function my_func($matches){ return ucwords($matches[0]); } echo preg_replace_callback("~\([^ A-Z)]+\)~", my_func, $str); ?>
|
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 09-26-2006 20:33
Ay it's not recognizing (blah) as a word, it needs to start alphabetic - really it's breaking for the same reason the first solution did.. code: <?php $str = "cool stuff (blah)"; function my_func($matches){ return "(".ucwords($matches[1]).")"; } echo preg_replace_callback("~\(([^ A-Z)]+)\)~", my_func, $str); ?>
|