Community
    • Login

    adding comma between numbers

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 4 Posters 7.0k 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.
    • Rabin malkomR Offline
      Rabin malkom
      last edited by

      hi
      how we can add comma between numbers for all lines
      like this below:
      “20:91BB80FB70A60DB6BFE53795BAD7EA851D8A44F212DD8A600679A835BCF7D433”=hex:3E015B4C179BC4275937EE946235EF5C

      “20:91BB80FB70A60DB6BFE53795BAD7EA851D8A44F212DD8A600679A835BCF7D433”=hex:3E,01,5B,4C,17,9B,C4,27,59,37,EE,94,62,35,EF,5C

      1 Reply Last reply Reply Quote 2
      • Alan KilbornA Offline
        Alan Kilborn
        last edited by

        This could work. Search for ("..:.{64}"=hex:)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..) and replace with ${1}${2},${3},${4},${5},${6},${7},${8},${9},${10},${11},${12},${13},${14},${15},${16},${17}. Use Regular expression search mode. It isn’t very “restrictive” on what it matches, but it could work (or you could make it more restrictive).

        1 Reply Last reply Reply Quote 4
        • guy038G Offline
          guy038
          last edited by guy038

          Hello, @rabin-malkom, @alan-kilborn and All,

          Not so hard ! I just assume that, only hexadecimal digits occur, right after the string =hex:. My solution is shorter than Alan’s one because I’m using the very useful assertion \G ;-))

          • Open the Replace dialog ( Ctrl + H )

          • SEARCH (?-is)(=hex:\K|\G)..(?!$)

          • REPLACE $0,

          • Tick the Wrap around option

          • Select the Regular expression expression mode

          • Click, exclusively, on the Replace All button ( Due to the \K syntax you must not use the Replace button ! )

          Notes :

          • First, the in-line modifiers :

            • Forces a non-insensitive way of searching ( (?-i) )

            • Forces the regex engine to interpret the regex . dot character as standing for a single standard char, only and not EOF chars ( (?-s) )

          • Then, the part (=hex:\K|\G) is an alternative between 2 zero-length locations :

            • The location right after the string =hex:, due to the \K syntax, which , in addition, resets the current search

            • The location right after the previous search ( \G ). So, after any two hexadecimal digits, previously matched

          • Now, the part .. simply matches two single standard characters

          • Finally, the negative look-ahead syntax (?!$) means that the overall match occurs only if  not followed with the end of the scanned line ( $ )

          • In replacement, the $0, syntax rewrites the overall match ( i.e. the two hexadecimal digits ), followed with a comma

          Best Regards,

          guy038

          1 Reply Last reply Reply Quote 4
          • PeterJonesP Online
            PeterJones
            last edited by PeterJones

            @guy038 said in adding comma between numbers:

            because I’m using the very useful assertion \G

            Nice.

            FYI, i’ve just tasked myself with npp-usermanual/issues/52, because the searching.md docs specifically forbid \G (apparently, older version of boost library didn’t accept it – actually, apparently boost 1.55 also accepted \G, so the old Wiki had been out of date for a long time; fortunately, we have the framework to fix the usermanual now, unlike in the locked-wiki days :-).)

            1 Reply Last reply Reply Quote 1
            • guy038G Offline
              guy038
              last edited by guy038

              Hi, @peterjones, and All,

              It necessary to point out that, in Notepad++, the \G assertion, in addition to the very end of the previous search, also matches :

              • The very beginning of the subject text ( obvious )

              • Any new location, deliberately created by the user, by moving the present caret location to an other one, between two clicks on the Replace button, when possible !

              Cheers,

              guy038

              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