Posted: Tue Nov 29, 2005 9:35 am
Take a look at your PCRE syntax again.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
$time=preg_split("/\d{2}.\d{2]/", "18.58");Code: Select all
<?php
$string = "DATA 1: testa DATA 2: testb DATA 3: testc";
$values = preg_split("/DATA \d+\: /", $string);
array_shift($values);
print_r($values);
?>Whaddya know... it's in the PHP Manual!robburne wrote:What is PCRE?
I'm not going to let you off the hook that easily this time. Go through your code step by step. If you can't figure it out, get The Regex Coach and input the pattern. See what it tells you.robburne wrote:Code: Select all
$time=preg_split("/\d{2}.\d{2]/", "18.58");
Code: Select all
$time=preg_split("/\d{2}.\d{2}/", "POD TIME: 18.00 ");Good. The function you'll want to use is preg_match_all(). What you are doing now, is splitting your string along each occurrence of two numbers separated by a dot. Using preg_match* you'll retrieve those numbers instead.robburne wrote:Thanks for the feedback, ok so it seems i have a typo in my expression . duh!
So with the change I am starting to get somewhere becuase.....
Is giving me...........Code: Select all
$time=preg_split("/\d{2}.\d{2]/", "POD TIME: 18.00 ");
"POD TIME: "
So I think this show I understand the regex, just that I am not using the function correctly as I wantthe second half of the expression not the first.
Rob.