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]
> --
> This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "
sup...@barebones.com" 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
bbedit+un...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/bbedit/910a3a89-87c5-4af5-b42a-e391d321bfb0%40googlegroups.com.