- Make sure you have a backup of your site. You can cause truly spectacular destruction with mass search and replace! OK, you've been warned!
- Open BBEdit, and select Find from the Search menu. The Find & Replace dialog will appear. (click to enlarge)
- Check "Use Grep" When you do this, you will notice it colors the grep wildcard characters red.
- paste this text into the Find box:
<!-- #BeginTemplate.+? -->
Leave the Replace With box blank (you want to replace the Begin Template tag with a blank). - Check the box for Multi-File Search, and Batch Find, then select select the folder on your local drive where the files reside.
- Click "Replace All." If you are the cautious type, and want to test it first, just click "Find" a couple of times, so that it will find the first result or two, and make sure it is highlighting the right tags.
- repeat using
<!-- #BeginEditable.+? -->
- Now uncheck Use Grep because the next two are standard exact match searches (no wildcards needed) then repeat the search and replace using
Ads by Google
Posted by ellen at September 27, 2006 04:30 PM
<!-- #EndEditable -->and then
<!-- #EndTemplate -->That's it - your files are now clean of template tags!
Ads by Google
It's amazing to me that DW doesn't allow for batch detachment. Thanks for confirming that for me. I had already done the grep replace mentioned below when I thought, "there must be a way to do this from Dreamweaver." Nope. I guess not.
Anyway, here's an improvement to your grep that doesn't require four separate searches. You can do it all with one, single grep search and replace like this:
\s*<!-- (#|instance)(begin|end)[^>]+-->
The \s* at the beginning will get rid of the blank line "hole" in your source code that would be left by deleting just the comment.
The '#' is actually 'instance' in my version of Dreamweaver (v8). I've made that an alternation grep.
All DWT comments immediately follow the above pattern with either "begin" or "end" (thus the alteration of "(begin|end)") for the extra check of accuracy.
There should be no ">" characters in there until the end of the comment tag, thus why my grep can is simplified to essentially say "any character but '>'" and then ending it will "-->" for the close comment.
I've tried this and it worked excellently to delete all of the template comments from files with one search and replace.
Is there a way to do this in windows? I don't have access to a mac and thus bbedit. I tried exectuing the following in cygwin to no avail:
grep \s*]+--> contact.html
The way that occurs to me off the top of my head would be to use a grep search in Eclipse. Eclipse is free, and very good - you probably should have it anyway!
See this link for an example:
http://gleichmann.wordpress.com/2007/11/21/search-and-replace-with-regular-expressions-in-eclipse/
Eclipse can be downloaded here:
http://www.eclipse.org/
I have Aptana installed and I use it time to time. I know it works as a plugin to eclipse but can I do the same thing there?
Also, is grep and regular expression the same thing?