From 18e57bb25e2d85e6a9fa04f82eefcb7bc12e4f57 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sun, 16 May 2010 06:24:41 +0000 Subject: [PATCH] Experimenting with word boundaries for non-word substitutions --- modules/ideone.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/ideone.pl b/modules/ideone.pl index d2372fa2..863b2c69 100755 --- a/modules/ideone.pl +++ b/modules/ideone.pl @@ -203,7 +203,7 @@ while($subcode =~ m/^\s*(and)?\s*replace\s*([^']+)?\s*'.*'\s*with\s*'.*'/i) { $last_char = $1 if $from =~ m/(.)$/; if($first_char =~ /\W/) { - $first_bound = '\B'; + $first_bound = '.'; } else { $first_bound = '\b'; } @@ -224,7 +224,9 @@ while($subcode =~ m/^\s*(and)?\s*replace\s*([^']+)?\s*'.*'\s*with\s*'.*'/i) { } } else { 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; } }