Community
    • Login

    I need to delete two characters in two continuous lines

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    12 Posts 6 Posters 1.4k 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.
    • Billy MartinB
      Billy Martin
      last edited by

      Thanks Alan, I’ve tried that expression but it says that cannot find the text.

      Alan KilbornA Meta ChuhM 2 Replies Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Billy Martin
        last edited by

        @Billy-Martin

        I copied the original text you gave out of the forum and into Notepad++. Then I used the Find expression I provided. It matched for me.

        1 Reply Last reply Reply Quote 1
        • Karsten75K
          Karsten75
          last edited by

          Just tried it the same as Alan, it worked for me and reported that two occurrences were found/deleted.

          1 Reply Last reply Reply Quote 0
          • Meta ChuhM
            Meta Chuh moderator @Billy Martin
            last edited by

            @Billy-Martin

            your original text is:

            [
                          -90.67575919025678,
                          14.12140539076991,
                          0
                        ],
                        [
                          -90.67691295444409,
                          14.11436171657998,
                          0
                        ],
            ...
            
            The thing is that I need to delete the last two characters in the square brackets the "," and the "0", so it must seem like:
            
            [
                          -90.67575919025678,
                          14.12140539076991
                        ],
                        [
                          -90.67691295444409,
                          14.11436171657998
                        ],
            

            you have to embed it between two lines of ``` (tripple backticks) otherwise your code gets stripped.

            best regards.

            Alan KilbornA 1 Reply Last reply Reply Quote 1
            • Billy MartinB
              Billy Martin
              last edited by

              Hi… Thanks… I’ve tried that in a new document and worked either. But in the original files the strings starts after three tab spaces… how can I add them into the search expression to match the string? is there any tab char I can add or how to add the 15 blank spaces between?

                      [
                        -90.89344601114183,
                        14.26720713414475,
                        0
                      ],
                      [
                        -90.89410910416692,
                        14.2672050050027,
                        0
                      ],
                      [
                        -90.89397902924168,
                        14.26244600987243,
                        0
                      ]
              
              1 Reply Last reply Reply Quote 2
              • PeterJonesP
                PeterJones
                last edited by

                @Billy-Martin ,

                I believe you should be able to update your find to: ,\R\h*0\R(?=\h*\]). The \h* adds a match of 0 or more horizontal spaces (space or tab).

                Actually, given your original spec, saying the closing ] should be on a separate line, I would actually say

                • ,\R\h*0(?=\R\h*\])
                  (which moves the newline after the 0 to not be deleted)

                For me, this converts

                        [
                          -90.89344601114183,
                          14.26720713414475,
                          0
                        ],
                        [
                          -90.89410910416692,
                          14.2672050050027,
                          0
                        ],
                        [
                          -90.89397902924168,
                          14.26244600987243,
                          0
                        ]
                

                to

                        [
                          -90.89344601114183,
                          14.26720713414475
                        ],
                        [
                          -90.89410910416692,
                          14.2672050050027
                        ],
                        [
                          -90.89397902924168,
                          14.26244600987243
                        ]
                
                1 Reply Last reply Reply Quote 2
                • guy038G
                  guy038
                  last edited by guy038

                  Hello @billy-martin, @peterjones and All,

                  Ah ! Nice, Peter, I was about to post a solution, but you beat me to it ;-))

                  And, of course, our solutions are identical

                  SEARCH ,\R\h*0(?=\R\h*\],)

                  REPLACE Leave EMPTY

                  So, I just give some explanations to Billy, on this regex S/R :

                  • The \R syntax represents any form of line-break ( \r\n for Windows files, \n for Unix files and \r for Mac files )

                  • The \h* part matches any range, even null, of horizontal blank characters, i.e. space, tabulation and no-breaking space character, of respective Unicode values \x{0020}, \x{0009} and \x{00A0 )

                  • The character [, being a regex meta-character, must be escaped with the \ character, to be interpreted as a literal

                  • So, the search regex looks for a comma, followed with a line-break, then some possible blank chars and, finally, a zero

                  • But ONLY IF the look-ahead structure (?=\R\h*\],) is true i. e. if the zero digit is immediately followed with a line-break, then possible blank characters and, finally, the string ],

                  • As the replace zone is empty, the search match ,\R\h*0, described above, is simply deleted

                  Best Regards

                  guy038

                  1 Reply Last reply Reply Quote 3
                  • PeterJonesP
                    PeterJones
                    last edited by

                    This has nothing to do with the main topic. Sorry for the tangent, but I’m curious:

                    @Meta-Chuh said:

                    @Billy-Martin,
                    your original text is:

                    Meta, how do you see what the original text was? In some other forums, I am able to view the source of the post, and that shows the pre-edited version… but I when I view the source in the Notepad++ Community forum, I don’t see anything with the spaces. Where did you get the original from?

                    1 Reply Last reply Reply Quote 2
                    • Billy MartinB
                      Billy Martin
                      last edited by

                      Thank you guys… it worked as expected and as desired.

                      Thanks a lot… it really helps me a lot and makes my life easier.

                      Best regards,

                      Billy

                      1 Reply Last reply Reply Quote 2
                      • Alan KilbornA
                        Alan Kilborn @Meta Chuh
                        last edited by

                        @PeterJones said:

                        Meta, how do you see what the original text was?

                        @Meta-Chuh YEA! How about it Meta??

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