Reorganize numbers



  • Hello
    I have a form like this:
    seven characters - three numbers - two - two numbers
    live example:
    7777777 - 123 - 12 - 12
    I want to reorganize the form and put every three i have in list in the last of the line
    to become like this
    7777777 - 12 - 12 - 123

    is this possible by using notepad++?
    Thanks!



  • “-” is just for separation purpose my form has no “-” inlcluded just spaces



  • Hello, @handa-flocka, and All,

    No problem with the regular expression support, natively included within Notepad++ !!

    We’re going to divide any line, with the layout dddddd•••••ddd•••••dd•••••dd ( where d represents a single digit and ••••• any range of characters ) into 7 parts which are stored as group 1, 2,… up to 7

    Then, in replacement, we just re-organize the order of these seven groups !


    • Open the Replace dialog ( Ctrl + H )

    • SEARCH (?-s)^(\d{7})(.+?)(\d{3})(.+?)(\d\d)(.+?)(\d\d)$

    • REPLACE \1\2\7\4\5\6\3

    • Tick preferably the Wrap around option

    • Select the Regular expression search mode

    • Click once on the Replace All button or several times on the Replace button

    Notes :

    • The first part (?-s) ensures that each regex . symbol will match a single standard character only

    • Note that any \d syntax represents an individual digit, possibly repeated

    • Any part .+? stands for the smallest range of non-null standard characters between two numbers

    • Each group n is created by embedding an expression between parentheses, in the search regex and re-used , in replacement, with the \n syntax

    Best Regards

    guy038



  • Thank you!! @guy038
    I got it and I got the idea thanks for further explanations


Log in to reply