Spaces in PHP files are sometimes problematic, so I'm trying to find files that meet common problem criteria. I try to find all recursive files that have one or both of these conditions:
1) Does not start with the character < or # .
and / or
2) Does not end with the > character, unless it ends in tight binding, followed by any number of newline lines.
I think the first condition would be the following: $[^<#]
I think the second condition would be the following: [ [^>^] | [}\n*^]] [ [^>^] | [}\n*^]]
However, note that in my naive regular expressions $ and ^ , the beginning and end of the file are represented, not any line in the file. And even with those, considering that they were correct, how would I combine them? Like this?
[$[^<
Then, putting them in grep:
grep -r [$[^<
Obviously this does not work (tm). Can someone teach me how to fix errors? Thanks.
This is a good file:
<?php ?>
Like this:
<?php function someFunc(){ } β
And this is also good:
#!/usr/bin/php -q <?php ?>
The leading HTML is excellent:
<html> <?php echo '</html>'; ?>
HTML trailing is good too:
<?php echo '<html>'; ?> </html>
This is bad (leading new line):
β <?php ?>
This is also bad (leading space):
β <?php ?>
This is also bad (the end line of a new line):
<?php ?> β