regex - pcregrep for finding all files with extra space before php opening tag -


i have working command line code using pcregrep finding php space after closing tag:

pcregrep -rml '\?>[\s\n]+\z' * 

i here: find space / new line after closing ?> (php tag)

now want know equivalent command above finding spaces before php opening tag @ beginning of php file:

[space here]<?php  

if know how this, please share thanks.

you can try pattern:

([\s\n]+)(?=\<\?php) 

you should try escaping < , ? since have specific meaning in regex. prefer around here since no need consume upcoming stuff , grouped results comes before php tag.

you can skip \n above pattern.

live demo


Comments

Popular posts from this blog

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -