adding comma between numbers

  • hi
    how we can add comma between numbers for all lines
    like this below:


  • 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).

  • 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 said in adding comma between numbers:

    because I’m using the very useful assertion \G


    FYI, i’ve just tasked myself with npp-usermanual/issues/52, because the 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 :-).)

  • 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 !



Log in to reply