Search notes:

Perl regular expressions: negative lookbehind

(?<!PATTERN)
#!/usr/bin/perl
use warnings;
use strict;
use feature 'say';

say match_to_end_of_sentence("Goerge, Ann and Peter went to the theater. They enjoyed it very much.");
#
# Goerge, Ann and Peter went to the theater.

say match_to_end_of_sentence("Also Dr. Hennson went there. But he didn't enjoy it.");
#
# Also Dr. Hennson went there.

sub match_to_end_of_sentence {

  my $text = shift;

  my ($sentence) = $text =~ /(.*?(?<!Dr)\.)/;

  return $sentence;
}
Github repository about-perl, path: /regular-expressions/negative-lookbehind.pl

See also

Perl regular expressions
Vim: negative lookbehind regular expression

Links

Perl's extended regular expressions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758201009, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Perl/regular-expressions/negative-lookbehind(69): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78