Problem One:
</a>
19-10-2011, 04:49 PM
</td> <td class="thread"
How to fetch the DATE and TIME i.e. 19-10-2011, 04:49 PM
Note: the above snippet could have unstable spacing as you see above e.g. </td> <td class
My attempt:
preg_match("#</a>(.*?)</td> <td class=\"thread\"#", $page, $fetchContent);
Result: empty
Problem Two:
<div id="post_message_43345">ANY TYPE OF CONTENT INCLUDING SPACES</tr> <tr>
I need to fetch “ANY TYPE OF CONTENT”.
Note: the spacing between tags such as </tr> <tr> could vary from page to another.
My attempt:
preg_match("#<div id=\"post_message_[a-zA-Z0-9_]*\">(.*?)</tr> <tr>#", $page, $fetchedContent);
Result: empty
I’m looking for rough temporary short snippet for one task. Therefore, i didn’t use HTML parser.
Any help will be appreciated.
Problem 1
You need to use the
sflag to have.match newline characters too:You’d probably be better off matching the date directly though:
edit – this date regex will be a little faster (added boundaries either side):
For both, the date is in
$results[1]and the time is in$results[2].Problem 2
Again the
sflag, and to have varying spaces between the</tr> <tr>use*.If you want to allow for newlines between the
</tr>and<tr>then do\s*instead. Same for Problem 1.