Skip to main content
added 87 characters in body
Source Link
Dom Hastings
  • 24.4k
  • 4
  • 56
  • 93

Perl 5 + -pl, 3431 bytes

Thanks to @DLosc for saving 3 bytes in the regex!

A different approach to @Xcali in their answer.

s/[^z]z*$.z*$/$&=~y!0-9a-z!1-9a-z0!r/e

Try it online!Try it online!

Explanation

Replaces any character that isn't z, followed by 0 or more zs, with the result of transliterating 0-9a-z to 1-9a-z0.

Perl 5 + -pl, 34 bytes

A different approach to @Xcali in their answer.

s/[^z]z*$/$&=~y!0-9a-z!1-9a-z0!r/e

Try it online!

Explanation

Replaces any character that isn't z, followed by 0 or more zs, with the result of transliterating 0-9a-z to 1-9a-z0.

Perl 5 + -pl, 31 bytes

Thanks to @DLosc for saving 3 bytes in the regex!

A different approach to @Xcali in their answer.

s/.z*$/$&=~y!0-9a-z!1-9a-z0!r/e

Try it online!

Explanation

Replaces any character, followed by 0 or more zs, with the result of transliterating 0-9a-z to 1-9a-z0.

Source Link
Dom Hastings
  • 24.4k
  • 4
  • 56
  • 93

Perl 5 + -pl, 34 bytes

A different approach to @Xcali in their answer.

s/[^z]z*$/$&=~y!0-9a-z!1-9a-z0!r/e

Try it online!

Explanation

Replaces any character that isn't z, followed by 0 or more zs, with the result of transliterating 0-9a-z to 1-9a-z0.