Delete all PHP closing tags at the end of all files

Delete PHP closing tags
Delete PHP closing tags with Sublime Text 2

I wanted to delete all PHP closing tags (?>) from a PHP project. So I used the following regex in Sublime Text 2 to delete them. (The leftmost button activates regular expressions)

(\s*\?>\s*)\z$

It only replaces the closing tags at the end of the file (\z = EOF).
Be sure to apply this only on *.php, and not on *.tpl files.

Edit:
Slight modification for finding files without a newline at the EOF.
(\s*.(?!\s+))\z$

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.