Search code examples
phpgrepeofeol

Grep check PHP files starting or ending with EOL


So, I just spend an hour looking through A LOT of php files for en EOL after a closing ?>. I tried regex matching it to make it easier, but with a big project \?>(\n){1,}$ still ended up getting me 450+ results. That, and the problem turned out to be an EOL BEFORE the opening <?php ...

So, I guess there HAS to be a better way. I was thinking GREP looking for files starting or ending with an EOL.

So what is the best way to solve these issues?


Solution

  • I ended up using a regex in Eclipse and searching all .php files.

    I ran /(^<?\s{1,}<\?php|\?>\s{1,}$)/g and found out I had two EOL before an opening <?php.

    This regex can also be used with grep.