aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2021-08-18 01:17:58 +0200
committerTeddy Wing2021-08-18 01:17:58 +0200
commitea3260541f81be7b288c20da920084271625b1a3 (patch)
tree8ae896b4aca84f24b1cb66de18f64f98c5db6848
parentea7e5214410ddb0ed53ccc27aed838a9c846e922 (diff)
downloadreadline-incdec-ea3260541f81be7b288c20da920084271625b1a3.tar.bz2
Test regex replacement starting from a given position
Set `pos()` to enable us to increment a number in the middle of a string.
-rw-r--r--pos.pl11
1 files changed, 11 insertions, 0 deletions
diff --git a/pos.pl b/pos.pl
new file mode 100644
index 0000000..f9c365f
--- /dev/null
+++ b/pos.pl
@@ -0,0 +1,11 @@
+#!/usr/bin/env perl -w
+
+use strict;
+
+my $test = 'test 12 0 45';
+
+$test =~ /(\d+)/g;
+pos($test) = 7;
+$test =~ s/\G([^\d]*)(\d+)/$1 . ($2 + 1)/e;
+
+print "$test\n";