You are here: Re: Getting class object information from file. « PHP Programming Language « IT news, forums, messages
Re: Getting class object information from file.

Posted by Toby A Inkster on 10/14/41 12:00

elmosik wrote:

> Multi line comments:
> '@/\*.*?\*/@ims'
>
> Hashed lines:
> '@^[\s|\t]+#.*?$@ims'
>
> Double slashed lines:
> '@^[\s|\t]+//.*?$@ims'

Regular expressions simply do not cut it. Consider the following comments
which will not be caught by your regular expressions:

define('SOME_CONFIG_OPTION', TRUE); # Here is a comment
define('SOME_OTHER_OPTION', TRUE); // Here is a comment

But what about the following code which contains no comments, which will
be treated as comments by your regexs:

$comment = "/* Lala */
// Lala
## Lala
No comments here!";
print $comment;

Regular expressions are no good for any non-trivial parsing task. You need
a stateful parser.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 17 days, 23:36.]

Gnocchi all'Amatriciana al Forno
http://tobyinkster.co.uk/blog/2008/01/15/gnocchi-allamatriciana/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация