I want to match "TEST:" in the following example:
$text = "TEST:
This is a test.";
preg_match_all("/^([A-Z]+)\:$/m", $text, $matches);
But $matches is empty.
This however does work:
$text = "TEST:
This is a test.";
preg_match_all("/^([A-Z]+).*\:*$/m", $text, $matches);
Output:
Array
(
[0] => Array
(
[0] => TEST:
[1] => This is a test.
)
[1] => Array
(
[0] => TEST
[1] => T
)
)
But I only want it to match "TEST:".
What am I doing wrong here? It seems to have a problem with the colon in the pattern, but doesn't work either if I don't escape it.
Thanks for help!