The basic idea is to define your search pattern with parentheses around the 
parts you want to use in the replacement. We might find the character name in 
all caps, two returns, and then the dialogue. You might need to add more \r 
return characters to match your source.

Search: ([A-Z ]+)\r\r(.*)\r
Replace: "\2" said \1.

Using the input string:

BILL

I like pizza.

This produces the output string:

"I like pizza." said BILL.

For the alternate source this might take the following form picking out the 
contents of the two <Text> tags and then using the same replacement pattern. 
The \s* is shorthand for any white space so we don't worry about how many tabs 
and returns there are.

Search: <Paragraph.*?>\s*<Text>(.*?)</Text>\s*</Paragraph>\s*<Paragraph 
Type="Dialogue">\s*<Text>(.*?)</Text>\s*</Paragraph>
Replace: "\2" said \1.


You can convert the character names from uppercase to title case using as 
second pass with a pattern like this. The (?-i) for case sensitivity. It finds 
words composed entirely of uppercase characters and then the replacement 
pattern capitalizes the first character and makes the rest lowercase. Watch out 
for acronyms and other input that might get converted. 

Search: (?-i)([A-Z])([A-Z]+)\b
Replace: \u\1\L\2


The Pattern Playground is useful for trying these out.

[fletcher]


> On May 10, 2020, at 3:31 AM, david nerlich <[email protected]> wrote:
> 
> Hi,
> 
> 
> 
> I’m trying to reformat screenplay dialogue into literary dialogue via grep. 
> Example:
> 
> 
> 
> BILL
> 
> 
> 
> I like pizza.
> 
> 
> 
> into 
> 
> 
> 
> “I like pizza” said Bill.
> 
> 
> 
> An alternate source to edit would be to use all the hidden characters from 
> Final Draft, eg:
> 
> 
> 
>  <Text>BILL</Text>
> 
>     </Paragraph>
> 
>     <Paragraph Type="Dialogue">
> 
>       <Text>I like pizza.</Text>
> 
> 
> 
> 
> 
> Thanks a bunch if anyone can advise how to do this. I’m a noob but I guess I 
> need a wildcard like .* but with a function that includes it in the replace 
> but preserving the unique name and dialogue in each instance. Hope that makes 
> sense. 
> 
> 
> 
> Dave
> 
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a feature 
> request or need technical support, please email "[email protected]" 
> rather than posting here. Follow @bbedit on Twitter: 
> <https://twitter.com/bbedit>
> --- 
> You received this message because you are subscribed to the Google Groups 
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/bbedit/910a3a89-87c5-4af5-b42a-e391d321bfb0%40googlegroups.com.

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/7154C6BB-3797-4359-8576-1DE2B1C885B9%40cumuli.com.

Reply via email to