<?php
function splitSentences($text) {
$re = '/# Split sentences on whitespace between them.
(?<= # Begin positive lookbehind.
[.!?] # Either an end of sentence punct,
| [.!?][\'"] # or end of sentence punct and quote.
) # End positive lookbehind.
(?<! # Begin negative lookbehind.
Mr\. # Skip either "Mr."
| Mrs\. # or "Mrs.",
| Ms\. # or "Ms.",
| Jr\. # or "Jr.",
| Dr\. # or "Dr.",
| Prof\. # or "Prof.",
| Vol\. # or "Vol.",
| A\.D\. # or "A.D.",
| B\.C\. # or "B.C.",
| Sr\. # or "Sr.",
| T\.V\.A\. # or "T.V.A.",
# or... (you get the idea).
) # End negative lookbehind.
\s+ # Split on whitespace between sentences.
/ix';
$sentences = preg_split($re, $text, -1, PREG_SPLIT_NO_EMPTY
); return $sentences;
}
$sentences = 'Entertainment media properties. Fairy Tail and Tokyo Ghoul.';
$sentences = splitSentences($sentences);
PD9waHAKCgogICAgZnVuY3Rpb24gc3BsaXRTZW50ZW5jZXMoJHRleHQpIHsKICAgICAgICAkcmUgPSAnLyMgU3BsaXQgc2VudGVuY2VzIG9uIHdoaXRlc3BhY2UgYmV0d2VlbiB0aGVtLgoJCSAgICAoPzw9ICAgICAgICAgICAgICAgICMgQmVnaW4gcG9zaXRpdmUgbG9va2JlaGluZC4KCQkgICAgICBbLiE/XSAgICAgICAgICAgICAjIEVpdGhlciBhbiBlbmQgb2Ygc2VudGVuY2UgcHVuY3QsCgkJICAgIHwgWy4hP11bXCciXSAgICAgICAgIyBvciBlbmQgb2Ygc2VudGVuY2UgcHVuY3QgYW5kIHF1b3RlLgoJCSAgICApICAgICAgICAgICAgICAgICAgICMgRW5kIHBvc2l0aXZlIGxvb2tiZWhpbmQuCgkJICAgICg/PCEgICAgICAgICAgICAgICAgIyBCZWdpbiBuZWdhdGl2ZSBsb29rYmVoaW5kLgoJCSAgICAgIE1yXC4gICAgICAgICAgICAgICMgU2tpcCBlaXRoZXIgIk1yLiIKCQkgICAgfCBNcnNcLiAgICAgICAgICAgICAjIG9yICJNcnMuIiwKCQkgICAgfCBNc1wuICAgICAgICAgICAgICAjIG9yICJNcy4iLAoJCSAgICB8IEpyXC4gICAgICAgICAgICAgICMgb3IgIkpyLiIsCgkJICAgIHwgRHJcLiAgICAgICAgICAgICAgIyBvciAiRHIuIiwKCQkgICAgfCBQcm9mXC4gICAgICAgICAgICAjIG9yICJQcm9mLiIsCgkJICAgIHwgVm9sXC4gICAgICAgICAgICAgIyBvciAiVm9sLiIsCgkJICAgIHwgQVwuRFwuICAgICAgICAgICAgIyBvciAiQS5ELiIsCgkJICAgIHwgQlwuQ1wuICAgICAgICAgICAgIyBvciAiQi5DLiIsCgkJICAgIHwgU3JcLiAgICAgICAgICAgICAgIyBvciAiU3IuIiwKCQkgICAgfCBUXC5WXC5BXC4gICAgICAgICAjIG9yICJULlYuQS4iLAoJCSAgICAgICAgICAgICAgICAgICAgICAgICMgb3IuLi4gKHlvdSBnZXQgdGhlIGlkZWEpLgoJCSAgICApICAgICAgICAgICAgICAgICAgICMgRW5kIG5lZ2F0aXZlIGxvb2tiZWhpbmQuCgkJICAgIFxzKyAgICAgICAgICAgICAgICAgIyBTcGxpdCBvbiB3aGl0ZXNwYWNlIGJldHdlZW4gc2VudGVuY2VzLgoJCSAgICAvaXgnOwoKICAgICAgICAkc2VudGVuY2VzID0gcHJlZ19zcGxpdCgkcmUsICR0ZXh0LCAtMSwgUFJFR19TUExJVF9OT19FTVBUWSk7CiAgICAgICAgcmV0dXJuICRzZW50ZW5jZXM7CiAgICB9CiAgICAKJHNlbnRlbmNlcyA9ICdFbnRlcnRhaW5tZW50IG1lZGlhIHByb3BlcnRpZXMuIEZhaXJ5IFRhaWwgYW5kIFRva3lvIEdob3VsLic7Cgokc2VudGVuY2VzID0gc3BsaXRTZW50ZW5jZXMoJHNlbnRlbmNlcyk7CgpwcmludF9yKCRzZW50ZW5jZXMpOw==