• Login
Community
  • Login

Please help me! How do you remove a certain character that only comes at the end of a line? Please help me!

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
please help me
11 Posts 4 Posters 2.3k 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.
  • A
    anontests
    last edited by Apr 3, 2021, 4:50 AM

    Please help me! How do you remove a certain character that only comes at the end of a line? Please help me!

    I need to remove the ‘’-‘’ character, but only if it comes at the end of every line, not if it’s in the middle.

    I also have the idea of making every lines text backwards, putting it in alphabetical order, so I can see where the ‘’-‘’ character is at the end, then reversing the text.

    But. I’m having trouble finding an answer that works in the latest notepad++ 64-bit I’m using. -

    Example. –

    – Change this –

    ads-asd-
    asdf-dfasdf-a-
    asafd-asdfs-
    a-s–d-f–ef-as-

    – To this –

    ads-asd
    asdf-dfasdf-a
    asafd-asdfs
    a-s–d-f–ef-as

    For over 9000 lines.

    That’s it.

    Please help me!

    T 1 Reply Last reply Apr 3, 2021, 5:30 AM Reply Quote 0
    • T
      Terry R @anontests
      last edited by Apr 3, 2021, 5:30 AM

      @anontests said in Please help me! How do you remove a certain character that only comes at the end of a line? Please help me!:

      I need to remove the ‘’-’’ character, but only if it comes at the end of every line, not if it’s in the middle.

      Use the Replace function. Make the search mode “regular expression”. Tick wrap around option.
      Find:-$
      Replace With: this field needs to be empty.
      Click on Replace All and the entire file will be processed.

      The $ sign denotes end of line. It doesn’t get deleted, just your character does.

      Terry

      A 1 Reply Last reply Apr 3, 2021, 6:04 AM Reply Quote 2
      • A
        anontests @Terry R
        last edited by Apr 3, 2021, 6:04 AM

        @Terry-R said in Please help me! How do you remove a certain character that only comes at the end of a line? Please help me!:

        @anontests said in Please help me! How do you remove a certain character that only comes at the end of a line? Please help me!:

        I need to remove the ‘’-’’ character, but only if it comes at the end of every line, not if it’s in the middle.

        Use the Replace function. Make the search mode “regular expression”. Tick wrap around option.
        Find:-$
        Replace With: this field needs to be empty.
        Click on Replace All and the entire file will be processed.

        The $ sign denotes end of line. It doesn’t get deleted, just your character does.

        Terry

        It works! Apparently!

        Thank you!

        Follow-up question! Sorry! One more thing.

        Please help me! How do you remove a certain character that only comes at the beginning of a line? Please help me!

        Example. –

        – Change this –

        -ads-asd-
        -asdf-dfasdf-a-
        -asafd-asdfs-
        -a-s–d-f–ef-as-

        – To this –

        ads-asd-
        asdf-dfasdf-a-
        asafd-asdfs-
        a-s–d-f–ef-as-

        For over 9000 lines.

        The reason I ask this is that I actually put all the lines in alphabetical order to remove the ‘’-‘’.

        So I would like to know how I can remove it from the beginning, while still keeping the same order.

        Sorry.

        Please help me!

        T 1 Reply Last reply Apr 3, 2021, 6:25 AM Reply Quote 0
        • T
          Terry R @anontests
          last edited by Terry R Apr 3, 2021, 6:26 AM Apr 3, 2021, 6:25 AM

          @anontests said in Please help me! How do you remove a certain character that only comes at the end of a line? Please help me!:

          Please help me! How do you remove a certain character that only comes at the beginning of a line? Please help me!

          Very similar solution. The ^ character represents the start of a line. These are very basic principles in regular expressions.
          So Find What:^-.

          So you should check out the links in the FAQ section about regular expressions. These are basic principles in regular expressions. I strongly suggest you start learning about them. You will be surprised how easy it is at the basic level to understand and write these.

          Terry

          A 1 Reply Last reply Apr 3, 2021, 6:58 AM Reply Quote 2
          • A
            anontests @Terry R
            last edited by Apr 3, 2021, 6:58 AM

            @Terry-R said in Please help me! How do you remove a certain character that only comes at the end of a line? Please help me!:

            @anontests said in Please help me! How do you remove a certain character that only comes at the end of a line? Please help me!:

            Please help me! How do you remove a certain character that only comes at the beginning of a line? Please help me!

            Very similar solution. The ^ character represents the start of a line. These are very basic principles in regular expressions.
            So Find What:^-.

            So you should check out the links in the FAQ section about regular expressions. These are basic principles in regular expressions. I strongly suggest you start learning about them. You will be surprised how easy it is at the basic level to understand and write these.

            Terry

            Oh. I see. Perfect!

            Thank you!

            I’m not sure where the FAQ section about regular expressions is.

            https://community.notepad-plus-plus.org/category/7/faq

            FAQ | Notepad++ Community

            As I can’t find something that exactly says that, and I’m not sure what you want me to look at specifically, or if it’s even this forum FAQ section.

            You don’t have to link to it. As I have my question answered now. But I don’t know where to go. Exactly.

            Oh. Sure. This post is probably good for people who look-up answers on the world wide web, or something, and don’t know much at all. And, again, I’m not sure where to look exactly. But. Sure. Thanks for the advice.

            Thank you!

            T A 2 Replies Last reply Apr 3, 2021, 7:12 AM Reply Quote 0
            • T
              Terry R @anontests
              last edited by Apr 3, 2021, 7:12 AM

              @anontests said in Please help me! How do you remove a certain character that only comes at the end of a line? Please help me!:

              I’m not sure where the FAQ section about regular expressions is

              FAQ Desk: Where to find REGEX documentation ?
              Is the post. Forgot it had the word REGEX which is just REGular EXpression shortened.

              Terry

              A 1 Reply Last reply Apr 3, 2021, 8:00 AM Reply Quote 1
              • A
                anontests @Terry R
                last edited by Apr 3, 2021, 8:00 AM

                @Terry-R said in Please help me! How do you remove a certain character that only comes at the end of a line? Please help me!:

                @anontests said in Please help me! How do you remove a certain character that only comes at the end of a line? Please help me!:

                I’m not sure where the FAQ section about regular expressions is

                FAQ Desk: Where to find REGEX documentation ?
                Is the post. Forgot it had the word REGEX which is just REGular EXpression shortened.

                Terry

                Oh okay.

                https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regex-documentation

                FAQ Desk: Where to find REGEX documentation ? | Notepad++ Community

                So I guess that’s it. Noted.

                Thank you!

                1 Reply Last reply Reply Quote 0
                • G
                  guy038
                  last edited by Apr 3, 2021, 8:29 AM

                  Hello , @anontests, @terry-r and All,

                  I’ve just updated the title of the Regex FAQ !

                  Best Regards,

                  guy038

                  A 1 Reply Last reply Apr 3, 2021, 9:13 AM Reply Quote 2
                  • A
                    anontests @guy038
                    last edited by Apr 3, 2021, 9:13 AM

                    @guy038 said in Please help me! How do you remove a certain character that only comes at the end of a line? Please help me!:

                    Hello , @anontests, @terry-r and All,

                    I’ve just updated the title of the Regex FAQ !

                    Best Regards,

                    guy038

                    Oh. Thank for that! That should be really helpful for new people who don’t know that an abbreviation of ‘‘REGular EXpressions’’ is ‘‘REGEX’’.

                    Thank you!

                    1 Reply Last reply Reply Quote 1
                    • A
                      Alan Kilborn @anontests
                      last edited by Alan Kilborn Apr 3, 2021, 12:06 PM Apr 3, 2021, 12:05 PM

                      Very similar solution. The ^ character represents the start of a line. These are very basic principles in regular expressions.
                      So Find What:^-

                      There’s a caveat with this one.
                      Say the line is like this: -------------I'm a line
                      Then a regex operation using ^- would affect ALL of the -, not just the first one.
                      HERE is another posting discussing an alternative technique to only handle the first character, when multiple of same are involved.

                      A 1 Reply Last reply Apr 3, 2021, 10:56 PM Reply Quote 3
                      • A
                        anontests @Alan Kilborn
                        last edited by Apr 3, 2021, 10:56 PM

                        @Alan-Kilborn said in Please help me! How do you remove a certain character that only comes at the end of a line? Please help me!:

                        Very similar solution. The ^ character represents the start of a line. These are very basic principles in regular expressions.
                        So Find What:^-

                        There’s a caveat with this one.
                        Say the line is like this: -------------I'm a line
                        Then a regex operation using ^- would affect ALL of the -, not just the first one.
                        HERE is another posting discussing an alternative technique to only handle the first character, when multiple of same are involved.

                        Oh.
                        Well, to be honest, I actually did want to remove all of them from the 1st and last line, and I think I just did ‘‘replace all’’ over and over again until they were all gone. Haha.
                        But, yeah, that’s useful for anyone that specifically needs to remove a certain character from the beginning, but wants to keep the same character.
                        Thank you!

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