You are here: Re: Help with regular expression please « PHP Programming Language « IT news, forums, messages
Re: Help with regular expression please

Posted by Alan on 07/21/07 09:55

"Noozer" <dont.spam@me.here> wrote in message
news:i%_ni.132646$1i1.126404@pd7urf3no...
> Trying to parse some strings .... My sample strings:
>
> Bob 1/0/X0 134 128 1 5 Data
> A comment line
> Bob 1/0/X2 84 82 25 0 COMPARTMENT1-3
> Bob 1/0/X1 1710 167 0 4 123 N/A
> Bob 11/0/X3 84 7 0 6 Data
>
> I'm trying to identify any string that starts with "Bob", then a space,
> then a digit OR a space, then #/#/X#, three spaces, a 1 to 4 digit number,
> some spaces, a 1 to 4 digit number, some spaces, a 1 to 4 digit number,
> some spaces, a 1 to 4 digit number, some spaces, some alpha characters.
>
> In my sample, the first, third and fifth strings would test positive.

preg_match('%^Bob\s+\d{1,2}/\d/X\d\s+\d{1,4}\s+\d{1,4}\s+\d{1,4}\s+\d{1,4}\s+[a-z]+.+%ix',$exstr);

I think previous reply may also match your example 4

hth
Alan

 

Navigation:

[Reply to this 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

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