You are here: Re: Help with Php and Regex « PHP Programming Language « IT news, forums, messages
Re: Help with Php and Regex

Posted by gosha bine on 05/31/07 16:41

On 31.05.2007 14:10 The.Relinator@gmail.com wrote:
> I'm just wondering what the best way is to extract and display a
> number from a html file.
>
> I tried the following piece of code, however it does not work.
>
> ereg('\d\.\d', $content, $reg);
> echo $reg[0];
>

Don't use ereg, it's deprecated.

preg_match_all('/-? ( \d+\.?\d* | \.\d+) /x', $html, $matches);

finds numbers like "12", "-123.456" and ".789" and places them in array
$matches.



--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok

 

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

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