VideoHelp Forum
+ Reply to Thread
Results 1 to 6 of 6
Thread
  1. I'm struggling to write a regular expression for the multiple expression function in Subtitle Edit

    What I want to do is select all one line subtitles (ie does not contain \N) and add "\N \N" at the end of the line making them 2 lines.

    This forces the subtitle to display the single or top line always in the same y position in the player I'm using.

    Subs will never be more than 2 lines

    Thanks in advance for any help.
    Last edited by ChocOrange; 22nd Jun 2023 at 15:55.
    Quote Quote  
  2. Try this awk command assuming that your subtitle file is named sub.srt

    Code:
    awk " /\134n/{ print $0} !/\134n/{print $0\"\134n\134n\"}"  sub.srt
    Quote Quote  
  3. Originally Posted by jack_666 View Post
    Try this awk command assuming that your subtitle file is named sub.srt

    Code:
    awk " /\134n/{ print $0} !/\134n/{print $0\"\134n\134n\"}"  sub.srt
    Thanks but it doesn't work as subtitle files are in the format: (it also makes every line just '\n\n')

    Code:
    1
    00:00:22,875 --> 00:00:24,250
    <i>Yes?</i>
    
    2
    00:00:25,333 --> 00:00:26,958
    I'll be right there.
    
    3
    00:00:42,875 --> 00:00:47,000
    <i>Imagine a world
    without information.</i>

    Subtitle edit reformats in the editor as per my request.
    I'd prefer a solution that works in SE.
    Last edited by ChocOrange; 22nd Jun 2023 at 12:33.
    Quote Quote  
  4. I was going to revise my script to exclude all lines that start with a numeral. But since you desire a solution that works in SE, I will take my leave.
    Quote Quote  
  5. Found a way in Subtitle edit in case anyone else needs it.

    Edit | Modify Selection. Use the 'Rule' drop down and choose 'Exactly one line'
    Right click on a selected line and choose 'Selected Lines > Multiple Replace' (There's no option in the standard Multiple Replace to apply only to selected lines).
    Use a replace of Regular expression Find: $ Replace \N \N
    Quote Quote  
  6. Member tren's Avatar
    Join Date
    Jan 2005
    Location
    Spain
    Search Comp PM
    I didn't know that feature and I like it!
    Thanks for sharing
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!