I am parsing email raw text bodies, and they have no HTML, so it’s a multi line string essentially.
I thought I created a regex to catch: Quote: #403 I need that back as [Quote, 403] from the entirety of this large string.
So heres an example:
$body = "
Test Person
Tester
(123) 123-1234
<mailto:xxxxxx@xxxxx.com> xxxxxx@xxxxx.com
xxxxxx@xxxxx.com
Your Information:
Name: Last, First
Email: xxxxxx@xxxxx.com <mailto:xxxxxx@xxxxx.co>
Phone: (123) 123-1234
Quote: #403";
preg_match('/^[a-zA-Z]+: #[0-9]+$/i', $body,$matches);
var_dump($matches); // => array(0) {}
Matches is empty. Based on my understanding this should have worked.
Thoughts?
>Solution :
Try removing the "start" and "end" characters and make it multi-line:
preg_match('/[a-zA-Z]+: #[0-9]+/m', $body,$matches);