Reply to Re: REGEXP problem

Your name:

Reply:


Posted by Pedro Graca on 10/12/06 16:17

frizzle wrote:
> Imagine the filename is index_en.html
> My output needs to be an array with the following:
> language => en (no underscore)
> file => index (no "_en")
> extension => html
>
> i created the following, but i don't know how to move on:
> preg_split( '/^[a-z0-9]*(_(en|_ru))?\.[a-z0-9]{2,4}$/', $filename );

preg_match() is your friend.

if (preg_match('/^([a-z0-9]*)(?:_(en|ru))?\.([a-z0-9]{2,4})$/', $filename, $matches)) {
$output['language'] = $matches[2];
$output['file'] = $matches[1];
$output['extension'] = $matches[3];
}


Reference: http://www.php.net/preg_match

--
File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

[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

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