0

I am trying to do a simple find and replace. I have:

  <?php $url = 'http://www.mywebsite.net/this-is-a-page.php'; ?>

as a variable on each page and I'm replacing it with:

  <?php $url = curPageURL(); ?>

I had my find set up like this:

   <?php $url =( .*); ?>

but that's clearly incorrect because it doesn't return any results when I hit find. Any help would be super appreciated.

Thanks!

davidcondrey
  • 34,416
  • 17
  • 114
  • 136
FTSoR
  • 41
  • 2
  • 9

2 Answers2

2

You need to escape some characters.

Try this <\?php \$url =( .*); \?>

  • ? denotes 0 or 1 of the previous character.
  • $ denotes end of line.

Escaping them changes them to literal matches.

CaffGeek
  • 21,856
  • 17
  • 100
  • 184
0

You have your capture group on the bit you want to replace instead of the bits you want to keep. I think you need something like this:

(<\?php \$url =)[^\?]+(\?>)

then replace it with

\1 curPageURL();\2

Not sure if TextMate uses \1 for reference or $1

garyh
  • 2,782
  • 1
  • 26
  • 28