I have following Perl regular expression that replaces number with results of evaled()ed Perl snippet:
$label =~ s/(\d+)999999(\D|\Z)/($1 +1) ."M$2"/xeg;
$label =~ s/(\d+)999(\D|\Z)/($1 +1) ."k$2"/xeg;
I have reviewed Python 2 and 3 documentation https://docs.python.org/3/howto/regex.html on Regular expressions, but can't find an equivalent in Python.
Any ideas?
In above examples, it cuts numbers that end with "999999" to suffix "M", and similarly for "999" to suffix "k". For example, number 1999999 becomes "2M" after replacement. Although this is not a how-to question for this specific example, but a more generic question if it's possible to have an eval()ed Python code as part of replacement generation?