Hi i'm trying to find all occurences of '<?' in my php code. I use eclipse for this, and i tried to search for the folowing pattern: "<\?^[p]" in the hope thi开发者_StackOverflow中文版s would return me all <? occrences, but not the <?php ones..
What's wrong about the regex? I thought I had figured out regular expressions, but it seams like i still have a long way to go :(
try this: <\?[^p]
I'm not familiar with Eclipse's regular expression language but I'd imagine you want this:
"<\?[^p]"
The difference is:
[^p]
means any character apart fromp
^[p]
means the start of a new line followed by ap
.
But you should check the manual for Eclipse to find out the exact regular expression syntax that Eclipse uses.
If all fails, you could use a trick with no regexes: replace your <?php
occurrences with something else (like for example THE_PHP_TAG
), then search for <?
, then replace THE_PHP_TAG
back to <?php
.
Edited
From what I understand you want to change <?
to <?php
. Try replacing <\?(?!php)
with <?php
. (This will prevent <?php
from turning into <?phpphp
).
精彩评论