So, I love using the PHP Short Tags
<?. They make my code look prettier and more clear. Also I just dislike repeating “php” everywhere in my code. But alas when I upgrade the PHP version on my Linode server I get errors. So I decided to replace them with the default
I don’t know much about regex but I was able to cobble together this little regular expression after some trial and error and it seems to catch most, if not all, of the situations while ignoring
<?xml and of course
<?=. It also catches those tags that are on their own lines.
Here it is:
I use VS Code so I searched my code with the above while making sure I enabled the regex option in the search panel. Hope it’s helpful to someone.
BTW: If you’re on a Mac and you need a good regex tool to help you build and test these, check out RegExRX on the Mac App Store. Really handy.