$string = "<!-- Start table -->Some text here<!-- End table -->"; $search_regex='/<!-- Start table -->(.*)<!-- End table -->/'; $result = preg_match($search_regex, $string, $match); echo count($match); //is 0! PHP: I cannot get this very simple preg_match to work. Any help, please?
Hmm, zes, that is correct. I simplified it. The string contains a lot of html, and it does indeed return zero. I am sure it contains the comments above.
Okay, here it is outputting 0: <?php $string="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"> <HTML> <HEAD> </HEAD> <body> <!-- Start table --> TEST <!-- End table --> </body> </HTML>"; $search_regex='/<!-- Start table -->(.*)<!-- End table -->/'; $result = preg_match($search_regex, $string, $match); echo count($match); //is 0! ?> PHP: i don't understand why it doesn't work...