Have you considered running php -s from the command line, which syntax highlights your source file for you, the searching for whatever color codes in your php.ini are used for functions? For that matter, you could custom-code the choices for the color and make the functions read in a separate php.ini On Sun, April 9, 2006 3:20 pm, Winfried Meining wrote: > > Hi, > > I am writing on a script that parses a PHP script and finds all > function calls > to check, if these functions exist. To do this, I needed a function > that would > strip out all text, which is enclosed in apostrophes or quotation > marks. This > is somewhat tricky, as the script needs to be aware of what really is > an > enclosed text and what is PHP code. Apostrophes in quotation mark > enclosed text > should be ignored and quotation marks in apostrophe enclosed text > should be > ignored, as well. Similarly, escaped apostrophes in apostrophe > enclosed text > and escaped quotation marks in quotation mark enclosed text should be > ignored. > > The following function uses preg_match to do this job. > > <? > > function stripstrings($text) { > while (preg_match("/^(.*)(?<!\\\)('|\")(.*)$/", $text, $matches)) { > > $front = $matches[1]; > $lim = $matches[2]; > $tail = $matches[3]; > > while (preg_match("/^(.*)(?<!\\\)('|\")(.*)$/", $front, $matches)) { > $front = $matches[1]; > $tail = $matches[3] . $lim . $tail; > $lim = $matches[2]; > } > > if (!preg_match("/^(.*)(?<!\\\)$lim(.*)$/", $tail, $matches)) > break; > > $string = $matches[1]; > $tail = $matches[2]; > while (preg_match("/^(.*)(?<!\\\)$lim(.*)$/", $string, $matches)) { > $string = $matches[1]; > $tail = $matches[2] . $lim . $tail; > } > > $text = $front . $tail; > } > > return($text); > } > > ?> > > I noticed that this function is very slow, in particular because > > preg_match("/^(.*)some_string(.*)$/", $text, $matches); > > always seems to find the *last* occurrence of some_string and not the > *first* > (I would need the first). There is certainly a way to write another > version > where one looks at every single character when going through $text, > but this > would make the code much more complex. > > I wonder, if there is a faster *and* simple way to do the same thing. > > Is there btw a script freely available, which can parse PHP code and > check for > errors ? > > Any help is highly appreciated. > > Winfried > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php