|
Posted by frizzle on 10/13/06 07:04
Pedro Graca wrote:
> 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
Thanks all.
I'll use John's or Pedro's way.
I am a little bit familiar with regex, but it's stuffed away somewhere
down there, and i can't reach it. Yet!!
Anyway, thanks a lot for your help!!
Frizzle.
Navigation:
[Reply to this message]
|