Jake McGraw wrote:
echo ereg_replace('__([:alnum:]{1})',strtoupper('\1'),'ss__name');

Problem:

strtoupper('\1') = '\1' => 'ssname'

Problem:

str_repeat('\1',5) = '\1\1\1\1\1' => 'ssnnnnname'

Solution:

preg_replace_callback('/__([a-z])/i', create_function('$a', 'return
strtoupper($a);'), 'ss__name');

Check out

PCRE (Perl Compatible Regular Expressions)
http://us3.php.net/manual/en/ref.pcre.php
preg_replace_callback http://us3.php.net/preg_replace_callback
create_function http://us3.php.net/create_function

Beat me to it, preg_replace_callback is probably better than /e from a readability and maintenance perspective too!

Dan
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to