Page 1 of 1

Simple expression

Posted: Tue Nov 29, 2005 9:21 am
by spacebiscuit
Ok,

I have read the tutorial I understand the tutorial yet this will not work...........

here is my string.......

"POD DATE: 18.58 POD TIME 123456"

I want to extract the time part of the string "18.58"

So I am using..........

Code: Select all

$time=preg_split("/\d{2}.\d{2]/", $message);
That is..... any occurence of 2 digits followed by a fullstop followed again by 2 occurences of a digit.

Can it be any simpler than that can it?

My output is giving me.........

Code: Select all

Array ( [0] => POD DATE: 18.58 POD TIME 123456 )
Now if you can tell me how that came about then you're a better programmer than me!

Thanks,

Rob.

Posted: Tue Nov 29, 2005 9:36 am
by foobar
Don't crosspost.

viewtopic.php?t=41324

Posted: Tue Nov 29, 2005 1:03 pm
by sweatje
you have a typo in your expression

Code: Select all

$time=preg_split("/\d{2}.\d{2]/", $message);
you have a ] instead of a } on the last quantity specifier

Posted: Tue Nov 29, 2005 1:20 pm
by foobar
sweatje wrote:you have a typo in your expression

Code: Select all

$time=preg_split("/\d{2}.\d{2]/", $message);
you have a ] instead of a } on the last quantity specifier
Good job letting people figure stuff out for themselves. Check out the other thread I linked to. :roll:

Posted: Tue Nov 29, 2005 2:31 pm
by John Cartwright
I've locked this thread since you've asked your question in another one one of your threads that is related to regex. We want to avoid people answering in 2 different area.
Good job letting people figure stuff out for themselves.
Thats not called for :?