Community
    • Login

    How to replace a character without affecting the other character with notepad?

    Scheduled Pinned Locked Moved General Discussion
    5 Posts 2 Posters 1.7k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Pedro ContrerasP
      Pedro Contreras
      last edited by Pedro Contreras

      Friends I have this problem, I need to replace the character: without affecting the other character like the previous one (:), for example

      ame: 1234: test
      journal:gift:5ty
      to
      ame1234: test
      journalgift:5ty

      please

      Scott SumnerS 1 Reply Last reply Reply Quote 0
      • Scott SumnerS
        Scott Sumner @Pedro Contreras
        last edited by

        @Pedro-Contreras

        Seems like you need to delete the first, and only the first. : on a line. Is that right? What if a line only has one :…does it still get removed?

        1 Reply Last reply Reply Quote 1
        • Pedro ContrerasP
          Pedro Contreras
          last edited by Pedro Contreras

          I need to eliminate the first one:
          They are more than 10000 lines, and they all have the:, as well as the example

          Scott SumnerS 1 Reply Last reply Reply Quote 0
          • Scott SumnerS
            Scott Sumner @Pedro Contreras
            last edited by

            @Pedro-Contreras

            Try this:

            Find what zone: ^([^:\r\n]*):
            Replace with zone: \1
            Wrap around checkbox: as you like it
            Search mode: Regular expression
            Action: Press Replace / Replace All button

            Here’s an explanation of how it works:

            THE FIND EXPRESSION:

            ^([^:\r\n]*):

            • [Assert position at the beginning of a line (at beginning of the string or after a line break character) (carriage return and line feed, form feed)][1 ] ^
            • [Match the regex below and capture its match into backreference number 1][2 ] ([^:\r\n]*)
              • [Match any single character NOT present in the list below][3 ] [^:\r\n]*
                • [Between zero and unlimited times, as many times as possible, giving back as needed (greedy)][4 ] *
                • [The colon character][5 ] :
                • [The carriage return character][6 ] \r
                • [The line feed character][6 ] \n
            • [Match the colon character][5 ] :

            THE REPLACE EXPRESSION:

            \1

            • [Insert the text that was last matched by capturing group number 1][7 ] \1

            Created with RegexBuddy

            [1 ]: http://www.regular-expressions.info/anchors.html
            [2 ]: http://www.regular-expressions.info/brackets.html
            [3 ]: http://www.regular-expressions.info/charclass.html
            [4 ]: http://www.regular-expressions.info/repeat.html
            [5 ]: http://www.regular-expressions.info/characters.html
            [6 ]: http://www.regular-expressions.info/characters.html#special
            [7 ]: http://www.regular-expressions.info/replacebackref.html

            1 Reply Last reply Reply Quote 2
            • Pedro ContrerasP
              Pedro Contreras
              last edited by

              @Scott-Sumner said:

              \1

              If you work the code, thank you very much friend, I thank you

              1 Reply Last reply Reply Quote 1
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors