Reply to Re: split with regex

Your name:

Reply:


Posted by Tom on 05/04/07 18:28

On Fri, 04 May 2007 13:35:19 -0400, Patrick wrote...
>
>Hello All,
>
>Been beating my head on the wall trying to get this working. Especially
>because of my *tweener level of php and regex experience.
>
>I have this $filename = C17AA001.000
>
>I want to split it like this $a = C17AA $b = 001 $c = .000
>
>I have tried this but can't get it to work.
>
>list($a, $b, $c,) = split("^[0-9a-zA-Z]{5}[0-9]{3}\.[0-9]{3}",$filename);
>
>echo $a;
>echo $b;
>echo $c;
>
>What am I missing here? Two days of googling and php.net have not
>cleared me up.
>
>Patrick
>
>
>
>*tweener - between novice and guru

If the text is always in the format, including number of characters, the substr
function may be easier to work with...

$a = substr('C17AA001.000', 0, 4);
$b = substr('C17AA001.000', 5, 7);
$c = substr('C17AA001.000', 8, 11);

Tom
--
Newsguy.com - Basic Accounts $39.95 / 12 months

[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

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