Re: Re: need some regex help to strip out // comments but not http:// urls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> It is possible to write a whole parser as a single regex, being it terribly
> long and complex.
> That said, there's no other simple syntax that would work, for example in
> javascript you could to the following:
> var http = 5;
> switch(value) {
>     case http:// Http case here! (this whould not be deleted)
>         // Do something
> }
> But most likely you wouldn't care about that..
>
> - Matijn

I would have to disagree. There are things that regex just can't at a
fundamental level grok. Things like nested brackets (e.g. the standard
blocking syntax of C, javascript, php, etc.). It's not a parser, and
despite all the little lookahead/behind tricks that enhanced regex can
do, it can't at a fundamental level _interret_ the text it sees. This
task involves interpreting what the text you're looking for actually
means, and should therefore be handled by something that can
interpret.

Also, (I haven't tested it, but) I don't think that example you gave
would work. Without any sort of quoting around the "http://";
, I would assume the JS interpreter would take that double slash as a
comment starter. Do tell me if I'm wrong, though.

-- 
--Zootboy

Sent from some sort of computing device.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux