caw
caw

Reputation: 31487

Regexes for quotations

I've already got help here for creating a quotation extraction function. Thanks alot, soulmerge!

Now I'm looking for regular expressions (PHP) which extract the cited text and the cited person. The person should be in one index (substring), the text in another index (substring).

For English texts, soulmerge proposed these regexes:

I would like to "translate" the following direct speech examples in German to regexes:

Can someone help me to build the adequate regular expressions for these direct speech forms?

I hope you can help me. Thank you very much in advance!

Upvotes: 1

Views: 199

Answers (1)

Yannick Motton
Yannick Motton

Reputation: 35971

  • /"(.+)",\s*sagte\s+(.+)/
  • /(.+)\s+sagte:\s*"(.+)"/

Please note that the person and question variables are reversed in the second regex.

Upvotes: 1

Related Questions