Are there any PHP libraries or tools available to assist in identifying "Plain Text" in templates?

One way to identify "Plain Text" in templates is to use regular expressions to search for text that is not surrounded by any HTML or PHP tags. This can be achieved by using the preg_match function in PHP with a regular expression pattern that matches plain text.

$template = "<h1>Hello, World!</h1> This is a plain text example.";
$pattern = '/(?<!<[^>]*)([^<]+)(?![^>]*>)/';
preg_match_all($pattern, $template, $matches);

foreach ($matches[0] as $match) {
    echo "Plain Text: " . $match . "\n";
}