我有以下字符串:
99001155
我想用 *
符号屏蔽最后 4 个字符。例如:
99001155 -> 9900****
怎么做?
最佳答案
str = "99001155"
str[-4..-1] = "****"
str
# => 9900****
关于ruby-on-rails - 字符串:用 * 号屏蔽最后 n 个字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23147302/