如果我有这样的字符串:
a = "11003.20140314143116.11003#13947822765031.ssint1.natvoice_nowithin_2txns.translatedalreadytotxt.pdf"
b = "11003.20140314143454.11003#13947824943836.ssint1.natvoice_nowithin_2txns.translatedalreadytotxt.pdf"
c = "11003.20140303131136.11003#13938270964818.telstra-alltxns-live_stripped-1.translatedalreadytotxt.pdf"
...如何在Ruby中修改它们,结果如下:
a = "ssint1.natvoice_nowithin_2txns.translatedalreadytotxt.pdf"
b = "ssint1.natvoice_nowithin_2txns.translatedalreadytotxt.pdf"
c = "telstra-alltxns-live_stripped-1.translatedalreadytotxt.pdf"
答案 0 :(得分:1)
所以你希望字符串以~z?
开头result = a.gsub(/\A[^a-z]*/, '')
如果您想要更改原始字符串,请使用
a.gsub!(/\A[^a-z]*/, '')