• Login
Community
  • Login

moving year in a date from the end to the front.

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
27 Posts 7 Posters 2.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.
  • V
    Vegard Johansen @Paul Wormer
    last edited by Jun 20, 2023, 1:17 PM

    @Paul-Wormer did not work :( maybe i do something wrong :(

    P 1 Reply Last reply Jun 20, 2023, 2:01 PM Reply Quote 0
    • G
      guy038
      last edited by guy038 Jun 20, 2023, 2:45 PM Jun 20, 2023, 1:26 PM

      Hello, @Vegard-Johansen, @gerdb42, @alan-kilborn, @wonkawilly, @paul-wormer and All,

      May be I should have given more details on my regex S/R !


      So :

      • Start N++ and open your document

      • Open the Replace dialog ( Ctrl + H )

      • Uncheck all box options

      • Enter (?<=\d)\x20+(?=\d) in the Find what : zone

      • Verify that the Replace with : zone is EMPTY

      • Check the Wrap around box

      • Select the Regular expression search mode

      • Click on the Replace All button

      => All the Space characters, which exist within numbers, should have disappeared !

      • Save the changes

      Best Regards,

      guy038

      V 1 Reply Last reply Jun 20, 2023, 1:54 PM Reply Quote 2
      • V
        Vegard Johansen @guy038
        last edited by Jun 20, 2023, 1:54 PM

        @guy038 said in moving year in a date from the end to the front.:

        (?<=\d)\x20+(?=\d)

        sorry but i cant understand what im doing wrong… But i cant get it to work :I

        P 1 Reply Last reply Jun 20, 2023, 2:05 PM Reply Quote 0
        • P
          Paul Wormer @Vegard Johansen
          last edited by Paul Wormer Jun 20, 2023, 2:08 PM Jun 20, 2023, 2:01 PM

          @Vegard-Johansen Did you include the double quotes in both the Find expression and the Replace expression? Did you have exactly one space between the digits? Did you check the regex mode box?

          My regex is a sort of brute force solution, I capture quotes and digits before and after a single space and copy them without a space in between them. @guy038 has a more sophisticated solution. He matches one (or more) space(s) that are surrounded by one digit on the left and one digit on the right and replaces the matching space(s) by an empty string.

          However, both methods work. I have tried them both.

          1 Reply Last reply Reply Quote 1
          • P
            PeterJones @Vegard Johansen
            last edited by Jun 20, 2023, 2:05 PM

            @Vegard-Johansen said in moving year in a date from the end to the front.:

            i cant understand what im doing wrong

            Could you give us a screenshot of your “Replace” dialog when you’re trying to use one of those regular expressions? We can probably figure out what setting you forgot to include.

            V 1 Reply Last reply Jun 20, 2023, 2:09 PM Reply Quote 0
            • V
              Vegard Johansen @PeterJones
              last edited by Jun 20, 2023, 2:09 PM

              @PeterJones @guy038 replace.jpg

              P 1 Reply Last reply Jun 20, 2023, 2:18 PM Reply Quote 0
              • P
                PeterJones @Vegard Johansen
                last edited by PeterJones Jun 20, 2023, 2:22 PM Jun 20, 2023, 2:18 PM

                @Vegard-Johansen ,

                Your Replace dialog looked right, so I went to your original post and (using my moderator powers) looked at the text you typed rather than what the forum rendered. When I copied from there and pasted into Notepad++, I saw
                535477dc-b5fe-4be0-adb7-cb552a2f1bec-image.png

                Please notice that the character between the -4 and the 497 is not a space; it is the special character NBSP (Non-breaking space). Because you said “i want to remove the space”, and did not accurately tell us what character was between there, we could not derive a regex that works. The \x20 in the regular expression only applies to the normal ASCII space character, not to a tab or to a NBSP or to any other space-like character.

                If your Notepad++ is not showing the NBSP symbol, then make sure you are on a relatively-recent Notepad++ version (v8.5 or newer), and make sure that View > Show Symbol > Show Non-printing Characters is turned on (has a checkmark next to it):
                563035f8-cebc-4d8d-a28c-d92d99133d9c-image.png

                But back to your question:

                Since we now know it’s a non-breaking space, we can change @guy038’s regular expression to (?<=\d)\xA0+(?=\d), and that will match just if there’s a non-breaking space between those characters. If there might be any horizontal space (real space, tab, nbsp, or others), then use (?<=\d)\h+(?=\d) instead, to make it match on any horizontal space.

                This shows the importance of knowing (and sharing) what the actual characters are.

                P V 2 Replies Last reply Jun 20, 2023, 2:23 PM Reply Quote 3
                • P
                  Paul Wormer @PeterJones
                  last edited by Jun 20, 2023, 2:23 PM

                  @PeterJones Good catch! I started to suspect something like that. Would we have seen it if he had cut and pasted his input into a code block?

                  P 1 Reply Last reply Jun 20, 2023, 2:28 PM Reply Quote 1
                  • P
                    PeterJones @Paul Wormer
                    last edited by PeterJones Jun 20, 2023, 2:31 PM Jun 20, 2023, 2:28 PM

                    @Paul-Wormer ,

                    Would we have seen it if he had cut and pasted his input into a code block?

                    Nope, the forum turns NBSP into a normal space, even in a code block. (I tried before posting my reply). Code boxes are better, but they don’t give 100% of what’s being pasted. (This forum software was designed for generic use, and isn’t specialized in being able to post things that tend more toward the “binary” nature rather than “normal text”)

                    For @Vegard-Johansen and others who don’t know, the “code boxes” are generated by:

                    1. Paste your text in the forum
                    2. select that text
                    3. Click the </> button on the forum’s post-editing toolbar :

                    This would take your text, and the edit panel would have shown

                    ```
                    "120000" "various" "646958" "20220323" "12" "firstname lastname" "-4 497" "20220407" "646958"
                    ```
                    

                    and it would render as

                    "120000" "various" "646958" "20220323" "12" "firstname lastname" "-4 497" "20220407" "646958"
                    

                    That would have been better than what you posted, because it at least showed the real quote marks rather than the “smart quotes” that we see in your post. But unfortunately, a special character like the NBSP doesn’t come through even then.

                    1 Reply Last reply Reply Quote 1
                    • G
                      guy038
                      last edited by guy038 Jun 20, 2023, 2:46 PM Jun 20, 2023, 2:45 PM

                      Hello, @Vegard-Johansen, @gerdb42, @alan-kilborn, @wonkawilly, @paul-wormer, @peterjones and All,

                      Good intuition, @peterjones, indeed !

                      I suppose that the Non Breaking Space characters are intentionally used between parts of a number. So, when the text of this document is wrapped, any number will be moved entirely to the next line and not separated in two parts ( one part at the end of a line and the remaining of the number on the next line )

                      BR

                      guy038

                      A 1 Reply Last reply Jun 20, 2023, 3:56 PM Reply Quote 0
                      • A
                        Alan Kilborn @guy038
                        last edited by Jun 20, 2023, 3:56 PM

                        Maybe answers in the future should use [\x20\xA0] to match spaces. :-(
                        Or maybe \h is often appropriate (but it isn’t as exacting).

                        P 1 Reply Last reply Jun 21, 2023, 8:17 AM Reply Quote 2
                        • V
                          Vegard Johansen @PeterJones
                          last edited by Jun 20, 2023, 8:27 PM

                          @PeterJones @guy038 @Alan-Kilborn @gerdb42 And everyone else :)

                          Thank so much, this community is so nice. it worked with this one: (?<=\d)\xA0+(?=\d) in the document. hopefully it will work tonight when the system import file. i will let you know 100% tomorrow :) Again thank you so much for all help!

                          1 Reply Last reply Reply Quote 0
                          • P
                            Paul Wormer @Alan Kilborn
                            last edited by Jun 21, 2023, 8:17 AM

                            @Alan-Kilborn Why not use \s? It matches all 17 Unicode space characters and also tabs, new line and new paragraph characters.

                            A 1 Reply Last reply Jun 21, 2023, 10:56 AM Reply Quote 1
                            • A
                              Alan Kilborn @Paul Wormer
                              last edited by Jun 21, 2023, 10:56 AM

                              @Paul-Wormer said in moving year in a date from the end to the front.:

                              Why not use \s

                              For the same reason that I hesitatingly recommended \h … because it opens up the match to more than what is wanted, a dangerous thing to do with regex.

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