On Fri, Feb 14, 2014 at 2:03 PM, Nickolas Whiting <prggmr@xxxxxxxxx> wrote: > Here is a regex that might do the trick ... I did not test this on a large > scale but it matches any "<?" that is not followed by php (<?php), or an > equal sign ignoring any whitespace (<?=$var?>, <? =$var;?>, <? = > $var?>) .... etc ... > > > http://regex101.com/r/bL0wO9 > > > On Fri, Feb 14, 2014 at 1:34 PM, Daevid Vincent <daevid@xxxxxxxxxx> wrote: > > > *sigh* > > > > <?=$foo?> is perfectly valid so is <?=$foo;?> or any combination WITH > > SPACES OR NOT. > > If this were trivial, I wouldn't have asked the list. I've been coding > PHP > > since 1996. ;-) > > > > So if you have <? you have to make sure it doesn't have a '=' after the > > '?' to convert to '<?php' > > > > Spaces are irrelevant and can NOT be relied upon as a unique feature. > > > > > -----Original Message----- > > > From: Daevid Vincent [mailto:daevid@xxxxxxxxxx] > > > Sent: Wednesday, February 12, 2014 2:57 PM > > > To: php-general@xxxxxxxxxxxxx > > > Subject: RE: Anyone have a tool/script to convert <? to <?php > (but > > not > > > <?=) > > > > > > Thanks guys for the replies so far, however, if it were a simple search > > and > > > replace I wouldn't have to ask ;-) > > > > > > The trick is that "<?=" is valid and legal and I want to keep those. I > > only > > > want to change if they are specifically "<?" > > > > > > Maybe there is some regex guru out there that knows the magic > > incantation. > > > > > > Related, for extra credit it drives me bonkers to see this: > > > > > > Hello <?= $username; ?> > > > > > > Note the end semicolon on the variable. I'd want to strip all those off > > too, > > > but that is also not a trivial task if you think about it as it can > only > > be > > > removed if proceeded with <?= > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > -- > Nickolas Whiting > Consultant > If your code is working, then you shouldn't worry about spaces since any space after ? followed by = or php will produce a parser error.