Add Missing Hyphens on second line when hyphen only exists on first line with regex

Viewed 37

Need to ADD missing hyphen on second line when hyphen only exists on first line only:

24
00:03:01,848 --> 00:03:04,893
- How adorable.
[both laughing]

48
00:02:53,798 --> 00:02:54,758
[clears throat]

49
00:02:57,552 --> 00:02:59,971
- [clears throat] Phil.
What can I get you?

168
00:07:01,421 --> 00:07:03,048
Really?
- If that's possible, yeah.

169
00:07:03,089 --> 00:07:04,007
- Really?
- Mm-hmm.

Here's what I thought might work [no cigar]:

Find:       ^([- ])(?=.*\r?\n([A-Za-z\[]))
Replace:    - $1

The CORRECT end results would be as follows with both lines having hyphens:

24
00:03:01,848 --> 00:03:04,893
- How adorable.
- [both laughing]

48
00:02:53,798 --> 00:02:54,758
[clears throat]

49
00:02:57,552 --> 00:02:59,971
- [clears throat] Phil.
- What can I get you?

Thanks in Advance, Hank

2 Answers

You want to match a line that starts with a - followed by a line that doesn't start with -. Use a negative lookahead to implement the "doesn't start with" criteria.

Then you want to add a - to the end of whatever this matched.

Find: ^-.*$\r?\n(?!- )(?=.) Replace: $0-

DEMO

Try (regex101):

^(-\s+.*?)^([^-])

with flags MULTILINE and SINGLELINE. Substitution is string:

$1- $2
Related