RegEx excludes academic title

I want the split paragraph line to be included in the sentence array. Of course, I use regex with a character dot (.) To split the paragraph into sentences. The problem is to shorten the academic name in sentences, each abbreviation uses a period (.). So my regex completely mistakenly separates the paragraph.

Here is an example paragraph:

Meanwhile, the rector of Bogor Agriculture University, Professor Gerry Suchardianto, in his comments requested that graduate students continue to study and refine their research on time. The general audience was attended by the Deputy Dean of the Graduate Student School of the Agricultural University of Bogor, Dr.Dedi Jusadi, Secretary of the Higher School Doctorate of the Bogor Agricultural University, Prof.Dr. Marimin

Just using dot (.) As regex, I get:

Array ( [0] => Meanwhile Rector of Bogor Agricultural University, Prof [1] => Dr [2] => Herry Suhardiyanto, in his remarks requested that the graduate students should keep on studying and will finalize their studies on time [3] => ... ) 

And this is actually what I wanted:

 Array ( [0] => Meanwhile Rector of Bogor Agricultural University, Prof. Dr. Herry Suhardiyanto, in his remarks requested that the graduate students should keep on studying and will finalize their studies on time [1] => Present in that general audience were the Deputy Dean of the Graduate School of Bogor Agricultural University, Dr.Dedi Jusadi, Secretary of the Graduate School for Doctoral Program of Bogor Agricultural University, Prof.Dr. Marimin ) 
+4
source share
2 answers

You can use Negative Lookbehinds:

((?<!Prof)(?<!Dr)(?<!Mr)(?<!Mrs)(?<!Ms))\. add more if necessary

Clarification demo: http://regex101.com/r/xQ3xF9

And the code might look like this:

 $text="Meanwhile Rector of Bogor Agricultural University, Prof. Dr. Herry Suhardiyanto, in his remarks about Mr. John requested that the graduate students should keep on studying and will finalize their studies on time. Present in that general audience were Mrs. Peterson of the Graduate School of Bogor Agricultural University, Dr.Dedi Jusadi, Secretary of the Graduate School for Doctoral Program of Bogor Agricultural University, Prof.Dr. Marimin."; $titles=array('(?<!Prof)', '(?<!Dr)', '(?<!Mr)', '(?<!Mrs)', '(?<!Ms)'); $sentences=preg_split('/('.implode('',$titles).')\./',$text); print_r($sentences); 
+3
source

This seems to work, but this is a new feature of PHP and strictly RegEx -

 $begin = array( 0=>'Meanwhile in geography,', 1=>'Dr', 2=>'Henry Suhardiyanto, in his remarks, stated that ', 3=>'Dr', 4=>'Prof', 5=>'Jedi Dusadi was another ', 6=>'Prof'); $exclusions = array("Dr", "Prof", "Mr", "Mrs"); foreach ($begin as $pos => $sentence) { if (in_array($sentence, $exclusions)) { $begin[$pos+1] = $sentence . ". " . $begin[$pos+1]; unset($begin[$pos]); array_values($begin); } } 
+1
source

All Articles