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

Re: Search and replace question

Expand Messages
  • Stefan Roemer
    ... Try ... Best regards Stefan
    Message 1 of 8 , Aug 1 5:28 AM
      On Fri, Aug 01, 2003, Kent Tenney wrote:
      > I have text using punctuation for underlining,
      >
      > Like This
      > +++++++++
      >
      > How can I find all occurances of a character repeated more
      > than once and replace them with the same number of a different
      > character?
      >
      > Like This
      > =========

      Try

      :%s/++\+/\=substitute(submatch(0),'+','=','g')/g

      Best regards

      Stefan
    • Kent Tenney
      Works great. Thanks for the instant solution. Kent
      Message 2 of 8 , Aug 1 5:50 AM
        Works great.

        Thanks for the instant solution.

        Kent

        Stefan Roemer wrote:

        > On Fri, Aug 01, 2003, Kent Tenney wrote:
        >
        >>I have text using punctuation for underlining,
        >>
        >>Like This
        >>+++++++++
        >>
        >>How can I find all occurances of a character repeated more
        >>than once and replace them with the same number of a different
        >>character?
        >>
        >>Like This
        >>=========
        >
        >
        > Try
        >
        > :%s/++\+/\=substitute(submatch(0),'+','=','g')/g
        >
        > Best regards
        >
        > Stefan
        >
        >
        >
      • Eric Leenman
        Hi, I have a file which outputs the following: [START OF FILE] Borland Delphi Version 14.0 Copyright (c) 1983,2002 Borland Software Corporation grfColor.dpr(1)
        Message 3 of 8 , Apr 15, 2005
          Hi,

          I have a file which outputs the following:

          [START OF FILE]
          Borland Delphi Version 14.0
          Copyright (c) 1983,2002 Borland Software Corporation

          grfColor.dpr(1)
          grfColor.dpr(12)
          grfColor.dpr(37)
          grfColor.dpr(37)


          GrfSysUtils.pas(3072)
          GrfSysUtils.pas(3187)

          Globals.pas(800)
          Globals.pas(867)

          grfColor.dpr(37)
          grfColor_TLB.pas(1)
          grfColor_TLB.pas(32)
          FormColorMain.pas(82)
          FormColorMain.pas(211) Warning: Constructing instance of 'TWaitingTaskThread' containing abstract method 'TThread.Execute'

          FormColorMain.pas(397)

          ColorCom.pas(163)
          ColorCom.pas(306) Warning: Return value of function 'TColorCom.AskNumOfColorCards' might be undefined

          ColorCom.pas(512)
          ColorCom.pas(1024)
          ColorCom.pas(318) Hint: Variable 'gArrayEric' is declared but never used in 'TColorCom.InitColorCard'

          ColorCom.pas(327) Hint: Variable 'lCamera' is declared but never used in 'TColorCom.InitColorCard'

          grfColor.dpr(37)
          grfColor.dpr(37)
          grfColor.dpr(37)
          grfColor.dpr(44)
          grfColor.dpr(55)
          37929 lines, 0.78 seconds, 177420 bytes code, 2497 bytes data.
          [END OF FILE]

          How to give the commands that delete:
          1) all empty lines?
          2) all lines which that end on '(<number>)' [might have a spaces after that] without having text after that?;

          So in the end I want to have left:

          [START OF FILE]
          Borland Delphi Version 14.0
          Copyright (c) 1983,2002 Borland Software Corporation
          FormColorMain.pas(211) Warning: Constructing instance of 'TWaitingTaskThread' containing abstract method 'TThread.Execute'
          ColorCom.pas(306) Warning: Return value of function 'TColorCom.AskNumOfColorCards' might be undefined
          ColorCom.pas(318) Hint: Variable 'gArrayEric' is declared but never used in 'TColorCom.InitColorCard'
          ColorCom.pas(327) Hint: Variable 'lCamera' is declared but never used in 'TColorCom.InitColorCard'
          37929 lines, 0.78 seconds, 177420 bytes code, 2497 bytes data.
          [END OF FILE]




          Best regards,

          Eric



          Disclaimer:
          De informatie verzonden met deze e-mail is uitsluitend bestemd voor de geadresseerde. Gebruik van deze informatie door anderen dan de geadresseerde is verboden. Greefa accepteert, mede gezien het onveilige karakter van berichten via internet, geen enkele juridische aansprakelijkheid voor de inhoud van dit bericht.
          The information contained in this communication is confidential and may be legally privileged. It is intended solely for the use of the individual or entity to whom it is addressed and others authorized to receive it. Use of this information , in whatever way, by others is strictly prohibited and may be unlawful. Greefa does not accept legal responsibility for this e-mail message due to the insecure nature of internet communications.
        • Otavio Correa Cordeiro
          Hi ... delete all blank lines :) Cya! ... --
          Message 4 of 8 , Apr 15, 2005
            Hi

            :g/^\s*$/d

            delete all blank lines :)

            Cya!

            On 4/15/05, Eric Leenman <ELeenman@...> wrote:
            > Hi,
            >
            > I have a file which outputs the following:
            >
            > [START OF FILE]
            > Borland Delphi Version 14.0
            > Copyright (c) 1983,2002 Borland Software Corporation
            >
            > grfColor.dpr(1)
            > grfColor.dpr(12)
            > grfColor.dpr(37)
            > grfColor.dpr(37)
            >
            > GrfSysUtils.pas(3072)
            > GrfSysUtils.pas(3187)
            >
            > Globals.pas(800)
            > Globals.pas(867)
            >
            > grfColor.dpr(37)
            > grfColor_TLB.pas(1)
            > grfColor_TLB.pas(32)
            > FormColorMain.pas(82)
            > FormColorMain.pas(211) Warning: Constructing instance of 'TWaitingTaskThread' containing abstract method 'TThread.Execute'
            >
            > FormColorMain.pas(397)
            >
            > ColorCom.pas(163)
            > ColorCom.pas(306) Warning: Return value of function 'TColorCom.AskNumOfColorCards' might be undefined
            >
            > ColorCom.pas(512)
            > ColorCom.pas(1024)
            > ColorCom.pas(318) Hint: Variable 'gArrayEric' is declared but never used in 'TColorCom.InitColorCard'
            >
            > ColorCom.pas(327) Hint: Variable 'lCamera' is declared but never used in 'TColorCom.InitColorCard'
            >
            > grfColor.dpr(37)
            > grfColor.dpr(37)
            > grfColor.dpr(37)
            > grfColor.dpr(44)
            > grfColor.dpr(55)
            > 37929 lines, 0.78 seconds, 177420 bytes code, 2497 bytes data.
            > [END OF FILE]
            >
            > How to give the commands that delete:
            > 1) all empty lines?
            > 2) all lines which that end on '(<number>)' [might have a spaces after that] without having text after that?;
            >
            > So in the end I want to have left:
            >
            > [START OF FILE]
            > Borland Delphi Version 14.0
            > Copyright (c) 1983,2002 Borland Software Corporation
            > FormColorMain.pas(211) Warning: Constructing instance of 'TWaitingTaskThread' containing abstract method 'TThread.Execute'
            > ColorCom.pas(306) Warning: Return value of function 'TColorCom.AskNumOfColorCards' might be undefined
            > ColorCom.pas(318) Hint: Variable 'gArrayEric' is declared but never used in 'TColorCom.InitColorCard'
            > ColorCom.pas(327) Hint: Variable 'lCamera' is declared but never used in 'TColorCom.InitColorCard'
            > 37929 lines, 0.78 seconds, 177420 bytes code, 2497 bytes data.
            > [END OF FILE]
            >
            > Best regards,
            >
            > Eric
            >
            > Disclaimer:
            > De informatie verzonden met deze e-mail is uitsluitend bestemd voor de geadresseerde. Gebruik van deze informatie door anderen dan de geadresseerde is verboden. Greefa accepteert, mede gezien het onveilige karakter van berichten via internet, geen enkele juridische aansprakelijkheid voor de inhoud van dit bericht.
            > The information contained in this communication is confidential and may be legally privileged. It is intended solely for the use of the individual or entity to whom it is addressed and others authorized to receive it. Use of this information , in whatever way, by others is strictly prohibited and may be unlawful. Greefa does not accept legal responsibility for this e-mail message due to the insecure nature of internet communications.
            >


            --
            | Otávio Corrêa Cordeiro
            | Bacharel em Física Teórica - FURG/RS
            | Mestrando em Computação Aplicada - Unisinos - HP
            | CSHuV - Centro de Simulação de Humanos Virtuais
            | http://otavio.geek42.org/ - ICQ: 16458106
            | GNU/Linux #268791
          • Strohhaecker, Bernd
            ... 1) :g/^ s*$/d 2) :g/( d +) s*$/d or with one command ... cu, Bernd
            Message 5 of 8 , Apr 15, 2005
              Eric Leenman [mailto:ELeenman@...] wrote at Friday, April 15, 2005 1:40 PM:

              > How to give the commands that delete:
              > 1) all empty lines?
              > 2) all lines which that end on '(<number>)' [might have a
              > spaces after that] without having text after that?;

              1) :g/^\s*$/d
              2) :g/(\d\+)\s*$/d

              or with one command

              :g/\(^\|(\d\+)\)\s*$/d

              cu, Bernd
            • Mathias Michaelis
              ... And ... (untested) should solve (1) and (2). Regards Mathias
              Message 6 of 8 , Apr 15, 2005
                >> How to give the commands that delete: 1) all empty lines? 2)
                >> all lines which that end on '(<number>)' [might have a spaces
                >> after that] without having text after that?;
                >>
                > :g/^\s*$/d
                >
                > delete all blank lines :)
                >
                And

                :g/^\(.*(\d\+)\)\?\s*$/d

                (untested) should solve (1) and (2).

                Regards
                Mathias
              • Eric Leenman
                Thanks for all the replies. Rgds, Eric Disclaimer: De informatie verzonden met deze e-mail is uitsluitend bestemd voor de geadresseerde. Gebruik van deze
                Message 7 of 8 , Apr 15, 2005
                  Thanks for all the replies.

                  Rgds,

                  Eric


                  Disclaimer:
                  De informatie verzonden met deze e-mail is uitsluitend bestemd voor de geadresseerde. Gebruik van deze informatie door anderen dan de geadresseerde is verboden. Greefa accepteert, mede gezien het onveilige karakter van berichten via internet, geen enkele juridische aansprakelijkheid voor de inhoud van dit bericht.
                  The information contained in this communication is confidential and may be legally privileged. It is intended solely for the use of the individual or entity to whom it is addressed and others authorized to receive it. Use of this information , in whatever way, by others is strictly prohibited and may be unlawful. Greefa does not accept legal responsibility for this e-mail message due to the insecure nature of internet communications.
                Your message has been successfully submitted and would be delivered to recipients shortly.