给出代码
thisString.sub! /piece\_[0-9]{1,4}.ts/, "piece_#{i}.ts"
其中thisString
可以是从piece_1.ts
到piece_9999.ts
如何获取被替换的号码?
答案 0 :(得分:0)
作为权宜之计,我最终获得了这个数字,然后做了子:
foundStartPiece = Integer(firstline[/piece\_[0-9]{1,4}.ts/][/[0-9]{1,4}/]) # Returns the number as an integer
编辑:之后,我确实转向使用@ndn的回答