aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2022-05-25 01:29:05 +0200
committerTeddy Wing2022-05-25 01:29:05 +0200
commitea3cd1980b86d647fb4a1d771489c93ebd1d77e0 (patch)
tree5260d67e1425953423c4549d1b73ba413ff10ed8
parent419f4cdec4c13c62c8c365a24ee5c59b59c66fdd (diff)
downloadreadline-incdec-ea3cd1980b86d647fb4a1d771489c93ebd1d77e0.tar.bz2
incdec.pm: Idea to keep leading zeros in numbers
-rw-r--r--incdec.pm4
1 files changed, 2 insertions, 2 deletions
diff --git a/incdec.pm b/incdec.pm
index a979cf7..39eaba4 100644
--- a/incdec.pm
+++ b/incdec.pm
@@ -30,7 +30,7 @@ sub incdec {
my $start_position = 0;
my $previous_match_start = 0;
my $i = 0;
- while ($line =~ /(-?\d+)/g) {
+ while ($line =~ /(-?[1-9]\d*)/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
@@ -64,7 +64,7 @@ sub incdec {
}
pos($line) = $start_position;
- $line =~ s/\G(-?\d+)/$1 + $increment_by/e;
+ $line =~ s/\G(-?[1-9]\d*)/$1 + $increment_by/e;
return ($line, $start_position);
}