Re: Anyone have a tool/script to convert <? to <?php (but not <?=)

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

 



Multiple regular expressions would be the way to go then.

Do the first one I sent (changing to <?phpcommand) then run another
matching something like <?php\w and replace with <?php $1<-- that's a
space

--jk

On 14 Feb 2014, at 14:55, Daevid Vincent wrote:

No I don’t want to change

<?
if ($foo)
?>

To

<?php if ($foo)
?>

That's ugly. And loses any block/indentations which help in readability.

What I want is to ONLY add a space in the case there is '<?command' so it becomes '<?php command' and not breaking it with '<?phpcommand' ... adding a space all the time makes other formatting ugly then as '<? command' becomes '<? command' with two spaces. I realize this may seem trivially cosmetic; I was just asking if that lookahead stuff can be applied to the replace portion as well somehow? Or maybe I run two separate regex matches on the parsed file to handle both cases since I intend to write a little .php script that will traverse a directory recursively to hit all the *.php files and re-write them (once this is tested of course)

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