I'm parsing through information in a file coming from a console, at the end of each line is the date, but the line may also have the date already listed in it. The input lines look like this:
00029 --> Ticket Received in QUEUE11 by ABCDE on 04/11/2013 at 11: 4/11/2013
00030 07:12. 4/11/2013
(there's a space before each line number and at the end of the line). My regex in my foreach
loop looks like this:
if (preg_match("/\s\d{5}\s(.+?)\d{1,2}\/\d{1,2}\/\d{1,4}\s
/", $line, $match))
{
$note = $match[1];
}
The regex is working in The Regex Coach and I can't find any reason why it won't work in my code. With the there, it matches no line, without it, it cuts off before the first date. I also tried and it behaves the same as having nothing. What I'm looking for is the final output to look like this once I've echoed $note in the loop.
Ticket Received in QUEUE11 by ABCDE on 04/11/2013 at 11:
07:12.
What am I missing?
Make the spaces at the end optional:
if (preg_match("/\s\d{5}\s(.+?)\d{1,2}\/\d{1,2}\/\d{1,4}\s*
/", $line, $match))
// here ___^
{
$note = $match[1];
}