Get 2 last letters of a string and increased

Hello,
how can i make the string “admin_X10-11_001” increased by 1 in order
to take “admin_x10-11_002”??

Thank you
K.

“admin_X10-11_001”.succ

Depending on how far you want to take it:

a = “admin_x10-11_001”
a.succ! # a = a.succ
a #=> “admin_x10-11_001”

Note:

“aby9”.succ # => “abz0”

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs