aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2022-05-26 16:50:43 +0200
committerTeddy Wing2022-05-26 16:50:43 +0200
commit48356a6720b735f86f930e7a41c7b0f297042a51 (patch)
treeb8391ce4561d7db20dc0f925947830a9226cf539
parentc74280c3c3f15915fbcb3f326a86633c92cd805c (diff)
downloadreadline-incdec-48356a6720b735f86f930e7a41c7b0f297042a51.tar.bz2
incdec.bash: Recompile with latest changes
-rw-r--r--incdec.bash6
1 files changed, 4 insertions, 2 deletions
diff --git a/incdec.bash b/incdec.bash
index 338afae..5c8f401 100644
--- a/incdec.bash
+++ b/incdec.bash
@@ -30,10 +30,12 @@ sub incdec {
$point_position ||= 0;
$is_backward ||= 0;
+ my $number_regex = '-?([1-9]\d*|0\D|0$)';
+
my $start_position = 0;
my $previous_match_start = 0;
my $i = 0;
- while ($line =~ /(-?\d+)/g) {
+ while ($line =~ /($number_regex)/g) {
if ($is_backward) {
# Set start position to the current match start. This gives us the
# correct start position when incrementing the last number in a
@@ -67,7 +69,7 @@ sub incdec {
}
pos($line) = $start_position;
- $line =~ s/\G(-?\d+)/$1 + $increment_by/e;
+ $line =~ s/\G($number_regex)/$1 + $increment_by/e;
return ($line, $start_position);
}