Reply to Regex

Your name:

Reply:


Posted by Colin Ross on 10/04/91 11:11

I'm trying to compress down a php-powered javascript file.
In the file i have php run a bunch of loops and foreaches to build
huge nested arrays for use in the javascript.
Since this will be an often loaded page with ALOT of backend
processing, I've decided to compress the file as much as I can and
cache the resulting 'js' file.
Trimming whitespace, etc have been easy in the buffer i have, but I'm
having trouble trying to remove empty javascript satements that do
nothing but add to the page weight.

code:

/*
remove useless statements like " case '15': { break;} "
*/
$buffer = preg_replace('/case(\s)?\'(\d)\'(\s)?:(\s)?[{](\s)?(break;)?(\s)?[}]/',
'', $buffer);


I have a bad feeling that its something in my regex, but can't quite
tell... I want it to allow for spaces (only), 'break;' should be
optional. and any number.

I usually tend to understand regexs, not sure why this one isn't working out...

Colin

[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

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