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

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -