Re: Regular expression question

From: Date: Thu, 11 Aug 2005 17:01:15 +0000
Subject: Re: Regular expression question
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-220449@lists.php.net to get a copy of this message
Hi Robin Many thanks for this, how would one extend this to support the following: $str = "insert into userComment (userID, userName, userSurname) values (0, 'Leon', 'mcDonald')"; one does not want $str = "insert into user_comment (user_id, user_name, user_surname) values (0, 'Leon', 'mc_donald')"; unfortunately lookbehind assertions does not support non-fixed length chars so /(?<=(?<!')[a-z])([A-Z]+)/e will work for 'mDonald' but the following will not work. /(?<=(?<!')([a-z]+))([A-Z]+)/e Any ideas? Many thanks -- Leon > <?php > $str = "insert into userComment (userID, userName, userSurname) values > (0, 'Leon', 'Vismer')"; > > $match = '/(?<=[a-z])([A-Z]+)/e'; > $replace = 'strtolower("_$1")'; > print preg_replace($match, $replace, $str); > ?> > > insert into user_comment (user_id, user_name, user_surname) values (0, > 'Leon', 'Vismer') > > -robin

« previous php.general (#220449) next »