mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-22 10:04:36 +01:00
Experimenting with word boundaries for non-word substitutions
This commit is contained in:
parent
dda750981b
commit
18e57bb25e
@ -203,7 +203,7 @@ while($subcode =~ m/^\s*(and)?\s*replace\s*([^']+)?\s*'.*'\s*with\s*'.*'/i) {
|
|||||||
$last_char = $1 if $from =~ m/(.)$/;
|
$last_char = $1 if $from =~ m/(.)$/;
|
||||||
|
|
||||||
if($first_char =~ /\W/) {
|
if($first_char =~ /\W/) {
|
||||||
$first_bound = '\B';
|
$first_bound = '.';
|
||||||
} else {
|
} else {
|
||||||
$first_bound = '\b';
|
$first_bound = '\b';
|
||||||
}
|
}
|
||||||
@ -224,7 +224,9 @@ while($subcode =~ m/^\s*(and)?\s*replace\s*([^']+)?\s*'.*'\s*with\s*'.*'/i) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
if($code =~ s/($first_bound)$from($last_bound)/if(++$count == $modifier) { "$1$to$2"; } else { "$1$from$2"; }/gex) {
|
my $unescaped = $from;
|
||||||
|
$unescaped =~ s/\\//g;
|
||||||
|
if($code =~ s/($first_bound)$from($last_bound)/if(++$count == $modifier) { "$1$to$2"; } else { "$1$unescaped$2"; }/gex) {
|
||||||
$got_change = 1;
|
$got_change = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user