I’ve bought RegexBuddy, given it a try and unless I am matching on something static, and simple – I just can’t get regex!
What I am trying to do is from the following line of text; I would like to extract tidal information into an associative array.
High Tide: 2.0m on Mon at 08.54pm and 2.4m on Tue at 09.18am
And end up with the following array:
[0] =
'Day' => 'Mon',
'Time' => '8.54pm',
'Height' => '2.0m',
'Tide' => 'High'
[1] =
'Day' => 'Tue',
'Time' => '09.18am',
'Height' => '2.4m',
'Tide' => 'High'
The concept I am struggling most with is the fact that there are multiple matches that I wish to extract (e.g. 2.0m and 2.4m). I’ve managed to match on 2.0m, and 2.4m, but how do I determine which one is which? (First High tide vs second high tide).
Any hints?
outputs
i probably got the thing about the low tide wrong so here is some code without the tide
outputs: