You are here: Re: remove all lines starting with b « PHP Programming Language « IT news, forums, messages
Re: remove all lines starting with b

Posted by Erwin Moller on 11/18/75 11:43

Geoff Berrow wrote:

> Message-ID: <4427b828$0$11073$e4fe514c@news.xs4all.nl> from Erwin Moller
> contained the following:
>
>>Read this:
>>http://nl3.php.net/manual/en/reference.pcre.pattern.modifiers.php
>>
>>So you could add the m modifier, like this:
>>echo preg_replace('/^b.*\\n/m','',$contents);
>>
>>where:
>>^b means begins with b
>>.* means: anything untill end of line (\n) is reached
>>\\n means the end of line
>>and the m outside the // means that your string is treated the way you
>>ment too (see description at www.php.net).
>
> I really have to learn more about regex. In the meantime...
>
> <?
> $contents = file('dummy.txt');
> foreach($contents as $value){
> echo ($value{0}!="b")? $value."<br>" : "";
> }
> ?>

Personally I prefer non-regex solutions too.
Regex is ok as long as I am able to read what it says, and the bigger
complex regex always give me headaches. :P

Regards,
Erwin Moller

 

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

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