Community
    • Login

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

    Scheduled Pinned Locked Moved General Discussion
    5 Posts 2 Posters 2.1k Views 2 Watching
    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 Offline
      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 Offline
        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 Offline
          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 Offline
            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 Offline
              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

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors