3
0
mirror of https://github.com/pragma-/pbot.git synced 2025-04-01 13:27:10 +02:00

-section now optional; instead, will check if search term starts with digits followed by a period, and if so, extract that as section

This commit is contained in:
Pragmatic Software 2010-04-12 21:56:09 +00:00
parent f9cd8ae88d
commit a56a297460

View File

@ -14,7 +14,7 @@ if(not length $search) {
my ($section, $paragraph, $section_specified, $paragraph_specified, $match, $list_only); my ($section, $paragraph, $section_specified, $paragraph_specified, $match, $list_only);
if($search =~ s/-section ([0-9\.p]+)//i) { if($search =~ s/-section\s*([0-9\.p]+)//i or $search =~ s/\b(\d+\.[0-9\.p]*)//i) {
$section = $1; $section = $1;
if($section =~ s/p(\d+)//i) { if($section =~ s/p(\d+)//i) {
@ -113,28 +113,30 @@ while($text =~ m/^\s{4}(\d+\.[0-9\.]*)/msg) {
} }
if(length $search) { if(length $search) {
eval {
# print "$p\n"; if($t =~ m/\b$search\b/ms) {
# print "[$t]\n"; $matches++;
if($matches >= $match) {
if($t =~ m/$search/ms) { if($list_only) {
$matches++; $result .= "$comma$this_section" . "p" . $p;
if($matches >= $match) { $comma = ", ";
if($list_only) { } else {
$result .= "$comma$this_section" . "p" . $p; $result = $t;
$comma = ", "; $paragraph = $p;
} else { $paragraph_specified = 1;
$result = $t; $found = 1;
$paragraph = $p; last;
$paragraph_specified = 1; }
$found = 1;
last;
} }
} }
};
if($@) {
print "Error in search regex; you may need to escape characters such as *, ?, ., etc.\n";
exit 0;
} }
} }
} }
last if $found == 1; last if $found == 1;
if($paragraph_specified) { if($paragraph_specified) {