Re: extract escaped quoted strings

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

 



On Sat, 2008-03-29 at 21:31 -0400, Adam Jacob Muller wrote:
> Yes, php source code.

You will not be able to do this with PCRE. You need something that can
track state because double quotes can appear within HTML outside of PHP
blocks, within HEREDOC, within double-quoted strings when backslashed,
and within single quoted strings. You need to account for each type of
PHP open/close semantic:

    <?php
    <?
    <?=
    <script language="php">

And that's just to determine script context. Then you need to know where
a double quote is. Is it starting a string? Is it within HEREDOC? Is it
within a single quoted string, etc. Your best bet is probably to use the
token_get_all() function:

    http://ca.php.net/manual/en/function.token-get-all.php

Cheers,
Rob.


> 
> 
> On Mar 29, 2008, at 8:54 PM, Robert Cummings wrote:
> 
> >
> > On Sat, 2008-03-29 at 20:41 -0400, Adam Jacob Muller wrote:
> >> Assume that you should accept any string that PHP itself would  
> >> accept,
> >> though no processing of the actual escapes is required nor desirable.
> >
> > Sorry, I wasn't clear enough :) By source I meant more along the lines
> > of what the text might look like from which these strings are being
> > pulled... for instance are you looking to pull these strings from PHP
> > source code? or something simpler?
> >
> > Cheers,
> > Rob.


-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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