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]

 



On Wed, May 29, 2013 at 1:33 PM, Matijn Woudt <tijnema@xxxxxxxxx> wrote:
>
>
>
> On Wed, May 29, 2013 at 7:27 PM, Sean Greenslade <zootboysean@xxxxxxxxx>
> wrote:
>>
>> > 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..
>> >
<SNIP>
> I think it should be possible, but as I said, very very complex. Let's not
> try it;)
>>
>>
>> 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.
>>
> Which is exactly what I meant. Because http is a var set to 5, it is a valid
> case statement, it would be equal to:
> switch(value) {
>     case 5: // Http case here! (this whould not be deleted)
>         // Do something
> }
>
> But any regex given above would treat the first one as a http url, and won't
> strip the // and everything after it, though in this modified case it will
> strip the comments.
>
> - Matijn

Sorry, I slightly mis-interpreted what that code was intending to do.
Regardless, it is still something that should be done by an
interpreter. So this is another edge case where regexes would more
than likely break down but an interpreter should (I do say should) do
The Right Thing.

-- 
--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