This:
ereg("([0-9]{1})-([0-9])-", $f, $regs);
What that means is "Capture a single occurance of 0-9, then a hyphen, then
capture a single occurance of 0-9 if it is imediately folowing by a hyphen."
Try this instead:
([0-9]{1})-([0-9]+)-
The "+" means "one or more". So "[0-9]+" is the same as "[0-9]{1,}". For
instance, "{x,y}" matches at least x amount of characters, but no more than
y amount of characters. Leave y off to match "x or more of the mentioned
characters". But don't forget that comma.
Regex is incredibly hard until you learn it. Then it doesn't seem hard
anymore :)
--
Plutarck
Should be working on something...
...but forgot what it was.
""Chad Day"" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> 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
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]