3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-22 18:52:40 +01: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);
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;
if($section =~ s/p(\d+)//i) {
@ -113,28 +113,30 @@ while($text =~ m/^\s{4}(\d+\.[0-9\.]*)/msg) {
}
if(length $search) {
# print "$p\n";
# print "[$t]\n";
if($t =~ m/$search/ms) {
$matches++;
if($matches >= $match) {
if($list_only) {
$result .= "$comma$this_section" . "p" . $p;
$comma = ", ";
} else {
$result = $t;
$paragraph = $p;
$paragraph_specified = 1;
$found = 1;
last;
eval {
if($t =~ m/\b$search\b/ms) {
$matches++;
if($matches >= $match) {
if($list_only) {
$result .= "$comma$this_section" . "p" . $p;
$comma = ", ";
} else {
$result = $t;
$paragraph = $p;
$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;
if($paragraph_specified) {