• Login
Community
  • Login

How to delete a character in lines with same beginning and ending, but different in between?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
9 Posts 5 Posters 1.2k 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.
  • P
    Polar Bear
    last edited by Oct 23, 2021, 2:34 PM

    I want to delete the [/b] in lines like these::
    [m3][c #0A5D00]▸[i] You’d get up early[/i][/b][/c][/m3]
    [m3][c #0A5D00]▸[i] We prefer cheese[/i][/b][/c][/m3]
    [m3][c #0A5D00]▸[i] They never came[/i][/b][/c][/m3]
    Of course there are other lines in the file with the same ending, and I want to leave them intact. for example:
    [m3][c #0A5D555]▸[b][i] charity fund[/i][/b][/c][/m3]
    What can I do? Please help.

    A P 2 Replies Last reply Oct 23, 2021, 2:59 PM Reply Quote 0
    • A
      Alan Kilborn @Polar Bear
      last edited by Oct 23, 2021, 2:59 PM

      @Polar-Bear

      The first step is to follow the instructions for submitting such questions, found HERE.

      P 1 Reply Last reply Oct 24, 2021, 4:05 AM Reply Quote 0
      • P
        Polar Bear @Alan Kilborn
        last edited by Oct 24, 2021, 4:05 AM

        @Alan-Kilborn Thanks for the instructions. I’ll try to follow them, though I’m not sure whether I can do it correctly.

        1 Reply Last reply Reply Quote 0
        • P
          PeterJones @Polar Bear
          last edited by Oct 24, 2021, 6:17 PM

          For others reading this conversation: This conversation was continued in “Deleting a group of characters in lines with same beginning and ending, but different in between (re-post)”.

          @Polar-Bear ,

          After replies have been made, please do not delete your post. That makes the conversation confusing. A moderator has restored your original post here for context.

          You could have just posted a new reply to this conversation, with the template-styled information, without needing a separate topic.

          1 Reply Last reply Reply Quote 0
          • W
            W TX
            last edited by Oct 24, 2021, 8:25 PM

            Here is the answer you want:
            3774ff3d-4e45-4551-b3e1-bbe44c86bf2a-image.png

            Command is:[/i].*[/c] to search for what you want to find

            596cff20-88bd-4d42-ba78-c5bdd9713659-Screenshot (582).png

            At replace position to enter what you want to replace:
            In your situation, replace = [/i][/c] to delete what you want to delete.

            comment:
            [] are metacharacters, if it is used, use ‘’ before ‘[’ to represent ‘[’ character
            .: Matches any single character (many applications exclude newlines, and exactly which characters are considered newlines is flavor-, character-encoding-, and platform-specific, but it is safe to assume that the line feed character is included). Within POSIX bracket expressions, the dot character matches a literal dot. For example, a.c matches “abc”, etc., but [a.c] matches only “a”, “.”, or “c”.

            : Matches the preceding element zero or more times. For example, abc matches “ac”, “abc”, “abbbc”, etc. [xyz]* matches “”, “x”, “y”, “z”, “zx”, “zyx”, “xyzzy”, and so on. (ab)* matches “”, “ab”, “abab”, “ababab”, and so on.

            Then use the replace key with item = what you want. In your case just delete “.*” in find command

            Tips:

            1. Before using Regex, at NP++, click View --> Show Simble --> Show All Characters as shown in pictures.
            2. Before replacing, click “Find Next” and it will show you what you want to identify.
            P P 3 Replies Last reply Oct 24, 2021, 8:29 PM Reply Quote 0
            • P
              PeterJones @W TX
              last edited by Oct 24, 2021, 8:29 PM

              @W-TX ,

              He already got multiple other working solutions in the other thread that was created.

              Though you inadvertently showed another reason for not starting a second copy of the same question: it makes people waste their time answering something that has already been answered.

              1 Reply Last reply Reply Quote 0
              • P
                Polar Bear @W TX
                last edited by Oct 25, 2021, 1:16 AM

                @W-TX Thanks for replying, but it seems you misunderstood my question.
                What I really want is to keep back everything except the [/b] element in lines beginning with [m3][c #0A5D00]▸[i], NOT in lines beginning with [m3][c #0A5D55]▸[b][i]. They have the same ending, but different beginning.

                1 Reply Last reply Reply Quote 0
                • P
                  Polar Bear @W TX
                  last edited by Oct 25, 2021, 3:40 AM

                  @W-TX Here’s a re-presentation of my question, followng a template suggested by Alan Kilborn.
                  Fellow Notepad++ Users,
                  Could you please help me the the following search-and-replace problem I am having?
                  I want to delete the [/b] in lines with the same beginning and ending, but different characters in between, like these:

                  Here is the data I currently have (“before” data):

                  [m3][c #0A5D00]▸[i] You’d get up early[/i][/b][/c][/m3]
                  [m3][c #0A5D00]▸[i] We prefer cheese[/i][/b][/c][/m3]
                  [m3][c #0A5D55]▸[b][i] charity fund[/i][/b][/c][/m3]
                  [m3][c #0A5D00]▸[i] They never came[/i][/b][/c][/m3]
                  [m3][c #0A5D55]▸[b][i] board of charity[/i][/b][/c][/m3]
                  
                  

                  Here is how I would like that data to look (“after” data):

                  [m3][c #0A5D00]▸[i] You’d get up early[/i][/c][/m3]
                  [m3][c #0A5D00]▸[i] We prefer cheese[/i][/c][/m3]
                  [m3][c #0A5D55]▸[b][i] charity fund[/i][/b][/c][/m3]
                  [m3][c #0A5D00]▸[i] They never came[/i][/c][/m3]
                  [m3][c #0A5D55]▸[b][i] board of charity[/i][/b][/c][/m3]
                  

                  To accomplish this, I have tried using the following Find/Replace expressions and settings
                  • Find What = [m3][c #0A5D00]▸[i]*[/i][/b][/c][/m3]
                  • Replace With = [m3][c #0A5D00]▸[i]*[/i][/c][/m3]
                  • Search Mode = all the three, one after another (REGULAR EXPRESSION, then NORMAL, then EXTENDED)
                  • Dot Matches Newline = NOT CHECKED
                  I tried the Find What function first, but it didn’t work, and I’m not sure why.
                  Could you please help me understand what went wrong and help me find the solution?
                  Thank you.

                  N 1 Reply Last reply Oct 25, 2021, 4:14 AM Reply Quote 0
                  • N
                    Neil Schipper @Polar Bear
                    last edited by Oct 25, 2021, 4:14 AM

                    @Polar-Bear

                    The cake is fully baked, wonderful scents are coming out of the kitchen, go to other thread here as mentioned by @PeterJones in his post above:

                    This conversation was continued in “Deleting a group of characters in lines with same beginning and ending, but different in between (re-post)”.

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