Combining Lines
-
Hello,
I am looking to condense a transcript that currently breaks up a speaker’s words into multiple lines:
John Doe: Hello.
John Doe: How are you today?
John Doe: I hope that you are well.
I would like to condense the lines into one resulting in the following:
John Doe: Hello. How are you today? I hope that you are well.
Is there a way to do this by removing the line breaks and the speaker’s name?
Thank you!
-
@Katherine-Curran said in Combining Lines:
Is there a way to do this by removing the line breaks and the speaker’s name?
Using regular expression search mode, yes
- FIND =
(?-s)^(.*?: )(.*?)\R+(\1)
- this says match up to the colon and space of the name, and store that as group 1; save the rest of the line as group2, match one or more newlines, and then see if the next non-blank line is the same as the previous speaker’s name
- REPLACE =
$1$2\x20
- the
$1$2
are the values of the two matched groups - the
\x20
is equivalent to a space, but easier to copy/paste from the forum - so replaces the old name/text/newlines/name with name/text/space, effectively doing what you wanted
- the
- MODE = regular expression
- run REPLACE ALL until it finishes (shows 0 replacements)
(there are even more complicated regex that would allow with only one REPLACE ALL, but the amount of time it takes to debug those super-fancy regex far outweigh the time to hit REPLACE ALL 3-4 times)
----Useful References
- FIND =
-
Find:
(?-s)^(.+?):(.+)\R\1:(.+)
Replace:${1}:${2}${3}
Wrap around: ticked
Search mode: Regular expression
Press Replace All repeatedly until the status bar of the Replace window indicates 0 replacements madeExample:
John Doe: Hello. John Doe: How are you today? John Doe: I hope that you are well. Bob Doe: Hello. Bob Doe: How are you today? Bob Doe: I hope that you are well. John Doe: Hello. John Doe: How are you today? John Doe: I hope that you are well.
After the first Replace All press:
John Doe: Hello. How are you today? John Doe: I hope that you are well. Bob Doe: Hello. How are you today? Bob Doe: I hope that you are well. John Doe: Hello. How are you today? John Doe: I hope that you are well.
Status bar indicates 3 replacements made.
After the second Replace All press:
John Doe: Hello. How are you today? I hope that you are well. Bob Doe: Hello. How are you today? I hope that you are well. John Doe: Hello. How are you today? I hope that you are well.
Status bar indicates 3 replacements made.
After the third Replace All press:
John Doe: Hello. How are you today? I hope that you are well. Bob Doe: Hello. How are you today? I hope that you are well. John Doe: Hello. How are you today? I hope that you are well.
Status bar indicates 0 replacements made. (Data transform was actually complete with the previous press, but that can only be determined via visual inspection).