Matching quotes
examples/regex-perl/sentences.txt
In <this text> there are <some in marks>, but there are more lines in this file and there are more <such symbols>. How can someone match sentences? A sentence - in our case, starts with a capital letter and ends with a dot.
examples/regex-perl/matching_quotes.pl
#!/usr/bin/perl use strict; use warnings; my $filename = 'sentences.txt'; my $content = slurp($filename); if ($content =~ /<.*>/) { print "$&\n"; print "-----------\n"; } # If we want the smallest: if ($content =~ /<[^>]*>/) { print "$&\n"; print "-----------\n"; } # If we want the biggest if ($content =~ /<.*>/s) { print "$&\n"; print "-----------\n"; } sub slurp { my $file = shift; open my $fh, '<', $file or die "Could not open '$file' $!"; local $/ = undef; my $all = <$fh>; close $fh; return $all; }