#!/usr/bin/php -->(.+?)<\!--<\/div>-->/sm', $contents, $matches, PREG_OFFSET_CAPTURE)) { foreach ($matches[1] as $match) { $passes = false; if (preg_match_all('/~~~ objc(.+?)~~~.+?~~~ swift(.+?)~~~/sm', $match[0], $languages)) { $objc = trim($languages[1][0]); $swift = trim($languages[2][0]); if (!empty($objc) && !empty($swift)) { $passes = true; } } if (!$passes) { list($before) = str_split($contents, $match[1]); $line_number = strlen($before) - strlen(str_replace("\n", "", $before)) + 1; echo "$file:$line_number\n"; } } } }