Reply to Re: split with regex

Your name:

Reply:


Posted by Patrick on 05/04/07 19:43

Aerik wrote:

> You're using split wrong - it's for "splitting it on boundaries formed
> by the case-sensitive regular expression" - the regex is the dividing
> boundary, not the text you're matching.
>
> Try this:
>
> $filename = 'C17AA001.000';
> preg_match("/([0-9a-zA-Z]{5})([0-9]{3})(\.[0-9]{3})/",$filename,
> $matches);
> //print_r($matches);
> list($x, $a, $b, $c,) = $matches;//discard x
> echo $a;
> echo $b;
> echo $c;
>
> Aerik (a tweener myself)
> http://www.wikidweb.com - the Wiki Directory of the Web
>
>

Sweet and thanks. That did it for me. And being able to get that part
working allowed me to finish and successfully test my php script which
basically renames a directory of files from

this

C17AC000.000
C17AC001.000
C17AC002.000
C17AC003.000
C17AC004.000
C17AC005.000
C17AC006.000

to this

C17AC.000
C17AC.001
C17AC.002
C17AC.003
C17AC.004
C17AC.005
C17AC.006

Regards,
Patrick

[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

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