Regular expression question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi 

I would like to convert from one naming convention within a sql statement to 
another.

I have the following,

<code>
$str = "insert into userComment (userID, userName, userSurname) values (0, 
'Leon', 'Vismer')";

$match = array(
"/([a-z]+)(ID)/",
"/([a-z]+)([A-Z])/"
);

$replace = array(
"\$1_id",
"\$1_\$2"
);

$nstr = preg_replace($match, $replace, $str);
echo $nstr ."\n";
</code>

the above gets me to 
insert into user_Comment (user_id, user_Name, user_Surname) values (0, 'Leon', 
'Vismer')

however I want to get to

insert into user_comment (user_id, user_name, user_surname) values (0, 'Leon', 
'Vismer')

Some help from the regex experts ;-)

Many thanks
--
Leon

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux