Returning part of a string, ereg..
| From: | Chad Day | Date: | Tue, 17 Apr 2001 13:36:55 +0000 |
| Subject: | Returning part of a string, ereg.. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-48960@lists.php.net to get a copy of this message | ||
I'm horrible at regex's, maybe someone can help me out.
What I'm trying to do is parse a string in the format: number-number-number
(ex. 1-23123-312039128)
I need to pull that second number, regardless of length
This code returns nothing:
$part = ereg("([0-9]{1})-([0-9])-", $f, $regs);
but
$part = ereg("([0-9]{1})-([0-9]{1,10})-", $f, $regs);
will return the number, but I don't want to take a chance and limit it to 10
characters. I thought the first bit of code would work.. any ideas what is
wrong?
Thanks,
Chad