Loading ...
Sorry, an error occurred while loading the content.
 

Search/Replace to remove everything between start and end code

Expand Messages
  • rdkelsey1113
    I use search/replace all the time in clips. I have found it to be incredibly helpful in assembling content into website pages. I’m confronted with an issue
    Message 1 of 3 , Mar 8, 2014

      I use search/replace all the time in clips. I have found it to be incredibly helpful in assembling content into website pages.

       

      I’m confronted with an issue that I thought I had a clip for, but I don’t … and the repository online is still not moved …

       

      I have an export file from a WordPress blog that is like this:

       

      <menustyle>whatever the content is for this field and then the close</menustyle>

       

      What I want to do is to remove both of the code’s, the start menustyle, and the end menustyle plus everything between them.

       

      I’m not a wizard with this stuff and can’t figure this out.

       

      --Robert

    • John Shotsky
      This will remove any spaces before or after this code, and any version of the menustyle command, even if it has a class= designation. If you want to remove a
      Message 2 of 3 , Mar 8, 2014

        This will remove any spaces before or after this code, and any version of the menustyle command, even if it has a class= designation. If you want to remove a CR at the end, just add \R* to the end of it so it doesn't leave a blank line. This works whether on separate lines or one big block of html. When I work with html, I generally close everything first into one big blob, then work on that, then separate as wanted. That's why the loop.

        ^!Replace "(?s)\x20*<menustyle.+?</menustyle>\x20*" >> "" ARSW

        ^!IfError Next Else Skip_-1

         

        Regards,
        John
        RecipeTools Web Site: http://recipetools.gotdns.com/recipetools/
        John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

         

        From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of rdkelsey1113@...
        Sent: Saturday, March 08, 2014 08:25
        To: ntb-clips@yahoogroups.com
        Subject: [Clip] Search/Replace to remove everything between start and end code

         

         

        I use search/replace all the time in clips. I have found it to be incredibly helpful in assembling content into website pages.

         

        I’m confronted with an issue that I thought I had a clip for, but I don’t … and the repository online is still not moved …

         

        I have an export file from a WordPress blog that is like this:

         

        <menustyle>whatever the content is for this field and then the close</menustyle>

         

        What I want to do is to remove both of the code’s, the start menustyle, and the end menustyle plus everything between them.

         

        I’m not a wizard with this stuff and can’t figure this out.

         

        --Robert

      • Axel Berger
        ... ^!Replace (?s) .*? WRASTI That s more or less verbatim what you requested above. The (?s) makes it dotall, i.e. the string
        Message 3 of 3 , Mar 8, 2014
          rdkelsey1113@... wrote:
          > both of the code’s, the start menustyle,
          > and the end menustyle plus everything between them.

          ^!Replace "(?s)<menustyle>.*?</menustyle>" >> "" WRASTI

          That's more or less verbatim what you requested above. The (?s) makes it
          dotall, i.e. the string between the tags may contain line ends. If you're
          sure that never happens in your case it's best to omit it. If you're sure
          the string can't contain other tags something like

          ^!Replace "<menustyle>[^<]*?</menustyle>" >> "" WRASTI

          would be safer. In cases like these you'd better be prepared for missing
          close tags or other mistakes and try to limit possible damage.

          Axel
        Your message has been successfully submitted and would be delivered to recipients shortly.