Re: Help with Php and Regex
- From: gosha bine <stereofrog@xxxxxxxxx>
- Date: Thu, 31 May 2007 18:41:15 +0200
On 31.05.2007 14:10 The.Relinator@xxxxxxxxx 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
.
- References:
- Help with Php and Regex
- From: The . Relinator
- Help with Php and Regex
- Prev by Date: Re: Collecting User Information
- Next by Date: Re: Intense CPU strain....suggestions
- Previous by thread: Re: Help with Php and Regex
- Next by thread: Variable substitution to replace switch
- Index(es):
Relevant Pages
|