Reply to Re: [PHP] Regular expression question

Your name:

Reply:


Posted by Leon Vismer on 08/11/05 20:01

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация