tags:

views:

68

answers:

4

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 this 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 :(

A: 

Edited

From what I understand you want to change <? to <?php. Try replacing <\?(?!php) with <?php. (This will prevent <?php from turning into <?phpphp).

Alexsander Akers
This will replace `<?php` with `<?phpphp`
NullUserException
Then afterwards you could replace `<?phpphp` with `<?php`. ;)
Mark Byers
@Mark LOL [ ](http://www.google.com)
NullUserException
+2  A: 

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 from p
  • ^[p] means the start of a new line followed by a p.

But you should check the manual for Eclipse to find out the exact regular expression syntax that Eclipse uses.

Mark Byers
thanks, seems i was pretty close :) thanks for the explanation. I didn't know ^[p] did what it does
Jules
+3  A: 

try this: <\?[^p]

vassilis
+2  A: 

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.

Eldad Mor