$line = qq~I'm looking for the end of a sentence, where possible. However, in some cases, I'll need to go with a non-conventional "end" to it, such as: "Here's a quote by a famous person which is supposed to exceed forty words and is therefore required to be set apart as a separate, indented paragraph per APA style." (Famous, 1999) Note that the regex needs to look for the full end of the sentence, if it exists: it cannot simply stop at the colon unless there is no further part to the sentence provided in that paragraph.~; $line =~ s/^ (.*?) ( (?:[.?!"]) #FIRST PRIORITY | (?:[:;-]) #SECOND PRIORITY | (?:\n|\r|\z|$) #LAST PRIORITY ) /$1$2/gmx; #### $line =~ s~^ ( Point\s(\d+)\.(\d+)\.(d+) (.*?) ) (?= (?:Point\s (?:\d+)\.(?:\d+)\.(?!\4) ) #1 Priority | (?:\z|$) #2 Priority ) ~$processthis->()~egmx;