You are here: Re: [PHP] Small regex help? « PHP « IT news, forums, messages
Re: [PHP] Small regex help?

Posted by Philip Hallstrom on 10/13/05 07:01

> Can anyone suggest the correct regex to replace col1,col2... with count(*)
> and strip out everything just before ORDER BY?
>
> so for this:
> SELECT col1,col2... FROM tbl WHERE filter1 filter2 ORDER BY order1,order2
>
> I would get this:
> SELECT count(*) FROM tbl WHERE filter1 filter2

$str = "SELECT col1,col2... FROM tbl WHERE filter1 filter2 ORDER BY order1,order2";

$str = ereg_replace("^SELECT .* FROM (.*) ORDER BY .*",
"SELECT COUNT(*) FROM \\1", $str);

 

Navigation:

[Reply to this 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

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