You are here: Re: grab succeeding string « PHP Programming Language « IT news, forums, messages
Re: grab succeeding string

Posted by Mladen Gogala on 05/11/06 04:03

On Wed, 10 May 2006 16:43:37 -0700, strawberry wrote:

> Say I have a chunk of text and I know that somewhere in that chunk ot
> text is the phrase 'Next Week's Winning Number will be:', is there a
> way I can automatically grab the string immediately following?
>
> Any help greatly appreciated.

Does the following snippet answer your question?

#!/usr/local/bin/php
<?php
$buff = "Next Week's Lotto: 123456";
if (preg_match("/Next Week's Lotto:\s*(\d+)/", $buff, $hit)) {
echo "Next week lottery:", $hit[1], "\n";
} else {
echo "You suck!\n";
}
?>


Of course, I make no claims that the next week's lottery numbers will be
"123456". No amount of regex massage will help you with that.

--
http://www.mgogala.com

 

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

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