简体   繁体   中英

Notepad++/Regex - How to conditionally switch the last 2 lines in a text file

I want to switch the last 2 lines of a file (so that the penultimate one is now the last one and reverse, BUT only in the situation where the penultimate line starts with a c. Preferably using any type of regex since I have to do this on various files.

thanks

You can try this with notepad++:

search: (?<=\n)(c.*)(\r?\n)(.*)\Z
replace: $3$2$1

("dot match newline" must not be checked)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM