If more then 2 line match add match line in front with /



  • Is there a way so i can run a command example.

    If more the 3-4 character match add NAME/ in front of x6128

    Orginal
    x6128k
    x6128m
    x6128c
    x6128m

    When done
    x6128/x6128k
    x6128/x6128m
    x6128/x6128c
    x6128/x6128m

    i have more then 14000 lines so that command will help a lot.



  • I hope I have read your question well enough to provide a solution. Please let me know if it needs adjustment due to something not shown in the example.

    Find What: ^(x6128)(k|m|c)(\R?)
    Replace with: \1/\1\2\3

    This is a ‘regular expression’, so in the Replace option in Notepad++ copy the red text into each of the 2 fields. Have the wrap around window ticked and regular expression selected, nothing else. If at all unsure of what it will do, run it by clicking the ‘Replace’ button, not the replace all. Once you are comfortable with it you could select the ‘Replace All’ button. My ‘regex’ assumes a carriage return/line feed is immediately behind the text. If this is not the case you will need to provide a more accurate example.

    Terry



  • it’s more complicated then that here is a line with more examples, i add a star of lines i have to ***/ add line in front

    tk895kr
    tk895m
    tk895c
    tk895y
    becomes
    tk895/tk895kr
    tk895/tk895m
    tk895/tk895c
    tk895/tk895y
    atmi5205be
    tk-5105m
    atmi5205ce
    atmi5205ye
    becomes
    atmi5205/atmi5205ce
    atmi5205/atmi5205ye
    k475c
    s307ac
    x3150xc
    h310kr
    h313mr
    h311cr
    h312yr
    Becoms

    h31/h310kr
    h31/h313mr
    h31/h311cr
    h31/h312yr
    becoms

    h310/h310kr
    h310/h313mr
    h310/h311cr



  • Well hopefully you can make other regexs using mine as a template. The regex I supplied is fairly simple to understand, the most complicated part is what we call alternation. That’s the 2nd last bracket. Thats where options exist, it has to be one of those character sets. Although I only have 1 character in each, you can have longer strings, I see one of the examples had 2 characters.

    Try and give it a go using my regex. We like people to at least try. If you can’t get it to work show us what you have tried.

    Terry



  • @Terry-R said:

    \1/\1\2\3

    dont think i am doing it right
    se picture link
    https://i.imgur.com/KZOMXSO.png



  • It looks like you pushed find, if so, it did exactly that. What you need to push is the replace button. If the first and possibly a few other hits of the replace button seem to be doing the job hit the replace all button. If will read the rest of the file and change all remaining occurances that fit.

    Did you try my regex first and check what that looked like when doing 1 change at a time?

    Just remember if at all unhappy with the changes either undo them all or don’t save the file when exiting. Also consider having a backup of the file before making any changes.

    Terry



  • Cant make it work even with replace all, just for make a better example what i have to do here is a list of printer ink, and all with a / have been manuel changes, and the command have to do the same job. and thanks for trying to help me :)

    the name is the printer same and the / in the ink types for that printer, just so you know what i am doing :)

    m775/m775k-n
    m775/m775m-n
    m775/m775c-n
    m775/m775y-n
    859001
    c410
    801000
    8009/800980
    8009/800990
    8009/800970
    h5949xcu
    o5100/o5100xk
    o5100/o5100xm
    o5100/o5100xc
    o5100/o5100xy
    tk150/tk150k-ntr
    tk150/tk150m-ntr
    tk150/tk150c-ntr
    tk150/tk150y-ntr
    s205xc
    s205xxc
    l644xcr
    atepc1100/atepc1100-b-cw
    atepc1100/atepc1100-m-cw
    atepc1100/atepc1100-c-cw
    atepc1100/atepc1100-y-cw
    o130/o130xbr
    o130/o130xmr
    o130/o130xcr
    o130/o130xyr
    h972/h9720kr
    h972/h9723mr
    h972/h9721cr
    h972/h9722ymr
    h267/h2670kr
    h267/h2673mr
    h267/h2671cr
    h267/h2672yr
    x3210xc
    h268/h2683mr
    h268/h2681cr
    h268/h2682yr
    r3400xxc
    s2850xc
    k1140c
    hf226/hf226x
    hf226/hf226a
    hf226/hf226a
    c524/c524k
    c524/c524m
    c524/c524c-ntr
    c524/c524y
    c522/c522k
    c522/c522m
    c522/c522c
    c522/c522y
    835601
    atnmc20/atnmc20-b-eu-cw
    atnmc20/atnmc20-m-eu-cw
    atnmc20/atnmc20-c-eu-cw
    atnmc20/atnmc20-y-eu-cw
    h53/h530k
    h53/h533m
    h53/h531c
    h53/h532y
    hf287/hf287x
    hf287/hf287a
    r1000c
    l240
    l340xc
    atmitk340.cw
    mlt-d305l/els
    x6128/x6128k
    x6128/x6128m
    x6128/x6128c
    x6128/x6128m
    k340c
    cep26u
    atokes3640a/atokes3640a-b-eu-cw
    atokes3640a/atokes3640a-m-eu-cw
    atokes3640a/atokes3640a–eu-cw
    atxe6350/atxe6350-B
    atxe6350/atxe6350-m
    ayut3012k-cw
    h38/h380xk
    h38/h383mr
    h38/h381cr
    h38/h382yr
    e6200xc
    dr6200-ntr
    sr407
    s4072/s4072k
    s4072/s4072m
    s4072/s4072c
    s4072/s4072y
    h973/h9730kr
    h973/h9733mr
    h973/h9731cr
    h9732yr
    c039x
    m880/m880k-ntr
    m880/m880m-ntr
    m880/m880m-ntr
    m880/m880y-ntr
    s5082/s5082xk
    s5082/s5082xm
    s5082/s5082xc
    s5082/s5082xy
    h32/h320br
    h32/h323mr
    h32/h321cr
    h32/h322y
    o431xc
    o411ac
    drb431-ntr
    atolp2026/atolp2026bx-cw
    atolp2026/atolp2026mx-cw
    atolp2026/atolp2026cx-cw
    atolp2026/atolp2026yx-cw
    tk55-ntr
    h41/h410xkr
    h41/h413mr
    h41/h411cr
    h41/h412yr
    h280ac
    h280xc
    k100u
    tk17-xl-ntr
    h255/h255xc
    h255/h255ac
    06a-ntr fx3
    b33/b3330
    b33/b3380
    b33/b3390
    bd3300
    fbrl-c746/fbrl-c746k
    fbrl-c746/fbrl-c746m
    fbrl-c746/fbrl-c746c
    fbrl-c746/fbrl-c746y
    s560rc
    atutp3065/atutp3065bx-cw
    atutp3065/atutp3065mx-cw
    atutp3065/atutp3065cx-cw
    atutp3065/atutp3065yx-cw
    tk725-ntr
    14a-ly-ntr
    hf214x
    xe-7100/xe-7100bk-c
    x7100/x7100k-2-ntr
    xe-7100/xe-7100m-c
    x7100/x7100m-2-ntr
    xe-7100/xe-7100c-c
    x7100/x7100c-2-ntr
    xe-7100/xe-7100y-c
    x7100/x7100-2-ntr
    h390xc
    rbrh-q5950/q6460
    h390ac
    hcf470/hcf470xk
    hcf470/hcf470xm
    hcf470/hcf470xc
    hcf470/hcf470xy
    atut3228kx-cw
    frbe-c3800/frbe-c3800m
    frbe-c3800/frbe-c3800m
    frbe-c3800/frbe-c3800c
    frbe-c3800/frbe-c3800y
    h600/h6000kr
    h600/h6003mr
    h600/h6001cr
    h600/h6002yr
    hcf450/hcf450ak
    hcf450/hcf450am
    hcf450/hcf450ac
    hcf450/hcf450ay
    s504/s504b
    s504/s504m
    s504/s504c
    s504/s504y
    tk440-ntr
    c510/c510B-hy-ntr
    c510/c510m-hy-ntr
    c510/c510c-hy-ntr
    c510/c510y-hy-ntr
    b2010
    h27/h270k
    h27/h273m
    h27/h271c
    h27/h272y
    o530/o530xk
    o530/o530xm
    o530/o530xc
    o530/o530xy
    o310/o310ak
    o310/o310am
    o310/o310ac
    o310/o310ay



  • I took another look at your image. You did not follow my instructions. I said select ‘regular expression’ you did not do that. The regex I supplied needs that to work properly.

    Also in your example you should have changed the ‘k’ to ‘kr’ which was one you were looking for. Do a search on the web for ‘regex and alternation’, there are sites that will show good examples.

    It’s good you are trying, you just need to follow instructions a bit better.

    Terry



  • @Terry-R

    It’s a lot of WORK, trying to be helpful! :-)


Log in to reply