regexmacoskomodoedit

Regex to remove all quote-parts from a text?


I have a film script and I need to remove all quotes, thus the parts where people are saying something, f.e.: "Martin:". Does someone know which regex I shoud use?

I'm using scripting language Perl. So the input I have is a whole filmscript. The output I want is that filmscript but without the parts where people talk. So "Martin: I'm hungry." should turn into "I'm hungry."

I tried "\w+\b:" in the find-bar but that selects all instances with a : in it. I tried to use ^ to mark the beginning of the line but it gave an error.

Hower names are not always single names. They can also be Scout Leader or Kid #1 , for example.


Solution

  • You can try this

    ^"[\w\s\d#]+:\s*
    

    Explanation

    ^ - Match the start of string.

    "[a-zA-Z][\w\s\d#]+: - Matches " followed by one or more alphabet or space or digit or #followed by :.

    -\s* - Matches zero or more space character.

    Demo