1

I am new to regex, I tried to search here the solution but cannot find yet. Would you mind kindly help me to rearrange this using regex in notepad++:

CEyYBUoAfhL.txt; "CEyYBUoAfhL-MI2.jpg" "CEyYBUoAfhL-MI3.jpg" "CEyYBUoAfhL-MI4.jpg" "CEyYBUoAfhL-MI5.jpg" "CEyYBUoAfhL-MI6.jpg" "CEyYBUoAfhL.jpg"
CEyYBUoAfhL.txt; "CEyYBUoAfhL-MI2.jpg" "CEyYBUoAfhL-MI3.jpg" "CEyYBUoAfhL.jpg"
CAjaBo1AL-9.txt; "CAjaBo1AL-9-MI2.jpg" "CAjaBo1AL-9-MI3.jpg" "CAjaBo1AL-9-MI4.jpg" "CAjaBo1AL-9.jpg" 

Need:

CEyYBUoAfhL.txt; "CEyYBUoAfhL.jpg" "CEyYBUoAfhL-MI2.jpg" "CEyYBUoAfhL-MI3.jpg" "CEyYBUoAfhL-MI4.jpg" "CEyYBUoAfhL-MI5.jpg" "CEyYBUoAfhL-MI6.jpg" 

Please note : I need to rearrange last element place as second element after xxxxxxx.txt;

2
  • To be clear, you want to move the last elelement to the second position? Or is there another rule? Please, edit your question and add more test cases.
    – Toto
    Dec 23, 2020 at 11:56
  • Yes, I need last element move to the second position. I already edit my question. Thanks. Hope you will help me to resolve this
    – Aku Aja
    Dec 23, 2020 at 12:36

1 Answer 1

1

Maybe you can use:

;\K(\s*.*?)(\s*\S+)$

And replace with

\2\1

Make sure to not tick the box where a dot would . matches newline.

See an online demo


enter image description here

4
  • 1
    Good job ;) you got my vote
    – Toto
    Dec 23, 2020 at 13:08
  • Thanks. Demo work. Thanks @JvdV But, after check carefully, its not work as expected on my end. Few of the pattern has SPACE at the end . Please kindly check [link] (regex101.com/r/ouoMeM/5)
    – Aku Aja
    Dec 23, 2020 at 13:51
  • I don't really understand exactly understand you but maybe you need ;\K(\s*.*?)(\s*\S+)\s*$ then @AkuAja ?
    – JvdV
    Dec 23, 2020 at 14:05
  • 1
    @JvdV Thanks. The last one work. You save my time. :) I vote your first answer. but it said Votes cast by those with less than 15 reputation are recorded, but do not change the publicly displayed post score.
    – Aku Aja
    Dec 23, 2020 at 14:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .