Tapatalk

Regular expression for multiple lines replace

Regular expression for multiple lines replace

1
NewbieNewbie
1

    Jan 28, 2005#1

    Looking for regular expression (I'd appreciate both UE & Unix style) which will take whole block of code and will insert some string before and after.
    Example:

    Code: Select all

    body
      {
      background-color: #fff;
      color: #000;
      margin: 0;
      padding: 0;
      text-align: justify;
      }
    when using replace dialog for eg. line with margin and padding selection it will produce this:

    Code: Select all

    body
      {
      background-color: #fff;
      color: #000;
    /*
      margin: 0;
      padding: 0;
    */
      text-align: justify;
      }
    Thanks for any help

    6,685587
    Grand MasterGrand Master
    6,685587

      Jun 25, 2006#2

      Can be done without a regular expression. After selecting the lines

      Code: Select all

        margin: 0;
        padding: 0;
      press Ctrl+R to open the replace dialog and enter in the find field ^s and in the replace field /*^p^s*/^p (for DOS terminated files or Unix/Mac files which are temporarily converted to DOS on load).

      If you want to use the "MakeBlockCmt" replace often, use a macro with a hot key. Here is the macro code:

      IfSel
      IfExtIs "css"
      Find "^s"
      Replace "/*^p^s*/^p"
      ExitMacro
      EndIf
      IfExtIs "html"
      Find "^s"
      Replace "<!-- ^s -->"
      ExitMacro
      EndIf
      IfExtIs "htm"
      Find "^s"
      Replace "<!-- ^s -->"
      ExitMacro
      EndIf
      EndIf


      See also Usage of ^c and ^s in search and replace.
      Best regards from an UC/UE/UES for Windows user from Austria