Skip to main content
sueb558855
Participating Frequently
July 25, 2019
Question

Replacing everything between two comment tags

  • July 25, 2019
  • 1 reply
  • 1607 views

I'm not much of a gun (at all) at regular expressions.

I need to replace everything between two comments with nothing.

I am trying to resurrect and clean up some HTML for someone whose site is only now available via the Wayback Machine.

So, I have lots (hundreds) of files with:

<!-- BEGIN WAYBACK TOOLBAR INSERT -->

I want to replace all of this HTML and, of course, the comments themselves

<!-- END WAYBACK TOOLBAR INSERT -->

I can do search & replaces on most other stuff but each of the comment sections is slightly different.

Is this possible? Thanks!

I'm using DW CS6 on a Mac.

    This topic has been closed for replies.

    1 reply

    Jon Fritz
    Community Expert
    Community Expert
    July 25, 2019

    If all of the comments are identical to what you put above, this should do the trick...

    1. With one of your pages open, open the Find & Replace tool
    2. Set the Find In dropdown to Current Document

    3. Put this in the Find field...

    <!-- BEGIN WAYBACK TOOLBAR INSERT -->

    (.)*?

    <!-- END WAYBACK TOOLBAR INSERT -->

    4. Verify that the Replace field is blank

    5. Make sure the Use Regular Expression box is checked
    6. Hit Replace All

    If it tests correctly on your open document, change the Find In dropdown to Entire Current Local Site and hit Replace All again.

    sueb558855
    Participating Frequently
    July 25, 2019

    Thank you, Jon.

    Unfortunately, nothing happened. I even tried just using the  (.)*?  on its own (because I could always not save, if the obliteration was total), but in both cases, DW returned "Done. Not found in the current document."

    It's a weird one. But thank you!

    WolfShade
    Legend
    July 25, 2019

    Not sure if you can do/find it, but don't forget to use the multi-line flag.  That might be affecting the results.

    V/r,

    ^ _ ^