How to separate specific text with notepad?

  • Actually reading through the examples I seemed to have overlooked the example staying the same order. I think that was only luck as we used a reverse sort and the first group were already in that mode.

    If however the sort changed the order to, say

    does that concern you?


  • friend I found a regex for the first group I managed to separate with (:. *? :), now I would only miss the second part, know some regular expression




  • What say I start again as I may have confused you with lots of options.

    Try the following on your original file.
    Find what: ^(?i)([a-z]+?)(:)(\d{2}):([a-z]+?)(\R)
    replace with: \1\2\4\5\3\2\4\5

    Once this is done you use the sort function to group the 2 different line types apart. So Edit, Line Operations, Sort lines lexicographically descending.

    See what that produces for you. If you are happy then just copy the 2nd group elsewhere (another file).

    If the result is NOT what you wanted let us know and maybe someone can give you a different regex to achieve it.


  • thank you friend for attending, I work well but for the 5 lines, but for 2000 or n lines?

  • You use search mode regular expression and hit the “Replace All” button. It should change the entire file. Have wrap around ticked as well.


  • I have about 2000 lines and I have marked regular mode expression and “Replace All” button, but it does not work

    Note: replace with: \ 1 \ 2 \ 4 \ 5 \ 3 \ 2 \ 4 \ 5, is it only for 5 lines?

  • Possibly the remainder of the lines do not fit the regex. Are the numbers 3 digits or more, my regex will only select 2 digit numbers as that’s what your example showed.

    Where it says d{2}, change the 2 to 3. If numbers exceed 3 digits then change 2 to 2,4. You may even need to increase further the 4 to say 8, depending on the range of numbers you have.

  • Hello, @yuly-pmem, @terry-r and All,

    I didn’t fully read all the posts, yet, but, personally, I would use the following method :

    • Do 2 copies of your 200000-lines text

    • Open the first copy in N++

    • Open the Replace dialog ( Ctrl + H )

    SEARCH :\d+


    • Select the Regular expression search mode

    • Tick the Wrap around option

    • Click on the Replace All button

    You should get the expected text :

    • Open the second copy, in N++

    SEARCH (?-s)^.+?:(?=\d+)


    This time, you should get the following text :


    Note that I use a look-ahead structure, (?=\d+), just in case your text contains other lines ( as, for instance, Section 1: or Example 2: ) with a : symbol, not followed with digits !

    Best Regards


  • friends guy038 and Terry the R: \ d + is for digits range 0-9, but if the case were like that

    freddy: darkkk12
    how would the method to separate them, with the previous method does not work

  • I dont know

  • @yuly-pmem are you able to tell us how you got on with the supplied regex’s? Have you tried any and if so what were the results.

    In order for us to help further we would need to know what you have tried, what didn’t work and also some more examples if a particular regex did NOT work as expected.

    @guy038 had a good idea. By copying the data, so you have 2 copies, you can create the individual groups you want independently. That also means once you have altered the text, it will still be in the same order as it started with. My idea would possibly have changed the order and that may not be what you wanted.


  • friend terry, if he works when there are numbers (literature: 18: trouble
    history: 10: medicine), but in some lines there are only letters like this
    history: text: ready
    medicine: small: student
    thanks anyway friend for wanting to help me.
    I will continue looking for the solution
    attentively yuli

  • From your last example it would appear that your data can be described as:
    string#1 then a : (colon) then string#2 then a : (colon) then string#3
    And furthermore string#2 may be some digits.
    And you would like it to be
    If the : is the delimiter then it should be easy enough to provide you a regex to change the data.

    First off, as @guy038 says, copy the entire file to another tab in Notepad++. So you should have 2 identical copies of the file (make sure the 2nd copy has a different file name as they need to be saved as different files).Add a blank line at the bottom of both files, so last line.

    In the 1st tab use the following regex to alter the text
    Find what: ^(.+?):.+?(:.+?\R)
    Replace with: \1\2
    search mode is “regular expression” and “wrap around” ticked.
    Once this is run you can remove the last blank line and save this file.

    In the 2nd tab (so this is the copy of the original file) use the regex:
    Find what: ^.+?:(.+?:.+?\R)
    Replace with : empty field here <— this means nothing in this field!
    search mode is “regular expression” and “wrap around” ticked.
    Once this is run you can remove the last blank line and save this file. Make sure this is a different file name, otherwise you will overwrite the results from the first regex.

    I hope this helps. My solution does rest on my description being accurate. If it is not then you need to provide it similar to how I did.


    PS as you have found out, your original example wasn’t good enough for us to help you properly. My description, had you included that at the start would have provided the extra information needed to supply you with a good solution.

  • Hello, @yuly-pmem, @ani-rodet, @terry-r and All,

    Ah OK ! So, here are, below, all the regexes to achieve the suppression of 1 or 2 columns, from an original 3-columns table, separated with colons ( : )

    Let’s imagine the initial 3-columns table, below :

    cell A1:cell B1:cell C1
    cell A2:cell B2:cell C2
    cell A3:cell B3:cell C3

    Then :

    • With the regex S/R :

    SEARCH :[^:\r\n]+$


    Only columns A and B remain :

    cell A1:cell B1
    cell A2:cell B2
    cell A3:cell B3
    • With the regex S/R

    SEARCH (?-s):.+(?=:)


    Only columns A and C remain :

    cell A1:cell C1
    cell A2:cell C2
    cell A3:cell C3
    • With the regex S/R :

    SEARCH (?-s)^.+?:(?=.+:)


    Only columns B and C remain :

    cell B1:cell C1
    cell B2:cell C2
    cell B3:cell C3
    • With the regex S/R :

    SEARCH (?-s):.+$


    Only column A remains :

    cell A1
    cell A2
    cell A3
    • With the regex S/R :

    SEARCH (?-s).+:(.+):.+

    REPLACE \1

    Only column B remains :

    cell B1
    cell B2
    cell B3
    • With the regex S/R :

    SEARCH (?-s)^.+:


    Only column C remains :

    cell C1
    cell C2
    cell C3



  • @guy038 said:


    I am very grateful for your help friends (guy038, terry), they are the maximum
    thank you teachers

    they work perfectly

Log in to reply