Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
正規表現でデクリメントしてみた
# -*- coding: utf-8 -*-
hoge = '99999999-1000'
/(-\d*)/ =~ hoge
tekitou = $&.to_i - 1
hoge.gsub!($&, tekitou.to_s)
print(hoge) # 99999999-1001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment