Move Line Up
-
Hello, my project manager wants me to move the “#DESCRIPTION” line above the “#SERVICE” line. Our master list contains several hundred entries. Can I highlight all “#DESCRIPTION” lines and move them above the “#SERVICE” line?
Thank you.
#SERVICE:4:8:1:6:0 #DESCRIPTION Angus #SERVICE:4:7:0:3:0: #DESCRIPTION Ayrshire #SERVICE:5:8:4:1:0 #DESCRIPTION Brown-Swiss #SERVICE:3:6:7:1:0 #DESCRIPTION Galloway #SERVICE:4:9:2:5:0 #DESCRIPTION Guernsey #SERVICE:6:4:7:8:0 #DESCRIPTION Hereford #SERVICE:2:7:4:1:0 #DESCRIPTION Holstein #SERVICE:6:4:2:9:0 #DESCRIPTION Piedmontese #SERVICE:3:6:3:1:0 #DESCRIPTION Scottish-Highland #SERVICE:4:4:9:3:0 #DESCRIPTION Shorthorn -
FIND =
(^#SERVICE.*)(\R)(^#DESCRIPTION.*)(\R?)
REPLACE =$3$2$1$2
SEARCH MODE =Regular ExpressionThis puts the
#SERVICEline in memory slot 1, the newline in memory slot 2, the#DESCRIPTIONin memory slot 3, and the second newline in slot 4. (But because files sometimes don’t end in a newline, I made it optional with the?The replacement uses slot 3, then 2, then 1, then 2 again, to swap the order of 1 and 3, and to make sure there’s always a newline, whether it was the last line of the file or not.
----
Useful References
-
Yes that works very well. Thank you so much. So the $ is a “backreference” in replacement strings when using regular expressions in the Find and Replace dialog?
Barry
-
Ok I see the “Useful References” link under Regex Special Characters for Searches, that explains it pretty well.
Thanks again.
Barry