Editing a list/ Moving words
-
Combining it all into one larger and more complicated expression is only really necessary if you have a need to do it over and over again. If it is just a one-time need, don’t worry about making it “efficient”.
-
@Mathew888 The folks helping you have deep knowledge of regex (which is a kind of programming language) and are very generous with their time.
Learning the basics of regex and what it can do may serve you very well down the road (not least because you will be in a position to look up complex features).
Nonetheless, this problem is also solved with np++ macros and no use of regex S&R. I achieved (what I take to be) your desired output:
Video Name A (Subtitles) 0:44 Video Name B (Subtitles) 11:32 Video Name C 10:03 Video Name D 0:36 Video Name E (Subtitles) 1:26:58 Video Name F 10:27
with 2 rounds of applying macros I recorded.
To prepare:
- In Preferences, Language, Tab Settings, normal (careful, choose what applies to you), ensure ‘Replace by space’ is not checked
- In find window, set Search mode = extended, search text = \nSubtitles; do at least one search. (Satisfy yourself that ‘Find’ does what you hope.) Caret to start of file.
First macro finds “Subtitles” at the start of a line (F3), and then does familiar editing to get the text on the prior line and add parenthesis.
After checking (maybe on a small file with a handful of entries) can save the macro and run it “Multiple times”. The very last instance might muck the last entry up, fix with Ctl-z.
Second macro does simple editing: cut text of video duration, delete line, navigate to end of the current line (name, maybe with subtitle), insert tab, paste duration, cursor to start of next entry.
Run macro on the whole file, again maybe fix up last entry.
It can be fun developing and checking macros; there’s much less reference material to plow through. You may need to fuss about various settings before you run it (and change back afterwards to what you prefer in normal editing), and, where you leave the cursor before you stop recording.
Regex’s is a much deeper topic than macros, but the latter can solve lots of problems, and in a more intuitive way.
-
@Neil-Schipper
Thanks for your info on Macros in this kind of situation, I’ve heard of them but have not used them previously.