PHP regex help with preg_match_all
Posted
by Steve
on Stack Overflow
See other posts from Stack Overflow
or by Steve
Published on 2010-03-25T04:29:44Z
Indexed on
2010/03/25
4:33 UTC
Read the original article
Hit count: 299
Hi, I am trying to refine a preg_match_all by finding the second occurrence of a period then a space:
<?php
$str = "East Winds 20 knots. Gusts to 25 knots. Waters a moderate chop. Slight chance of showers.";
preg_match_all ('/(^)((.|\n)+?)(\.\s{2})/',$str, $matches);
$dataarray=$matches[2];
foreach ($dataarray as $value)
{ echo $value; }
?>
But it does not work: the {2} occurrence is incorrect.
I have to use preg_match_all because I a scraping dynamic HTML.
I want to capture this from the string:
East Winds 20 knots. Gusts to 25 knots.
Any ideas? Thx
© Stack Overflow or respective owner