【发布时间】:2011-09-03 17:22:45
【问题描述】:
我有一个文件名数组。其中的一个子集可能有类似这样的模式(字母字符串末尾有一个数字):
arr = %w[
WordWord1.html
WordWord3.html
WordWord10.html
WordWord11.html
AnotherWord1.html
AnotherWord2.html
FileFile.html
]
如何识别相似的(它们具有相同的子字符串,只是它们的数字不同)并将它们移动到数组中?
['WordWord1.html', 'WordWord3.html', 'WordWord10.html', 'WordWord11.html']
['AnotherWord1.html', 'AnotherWord2.html']
['FileFile.html']
【问题讨论】:
标签: arrays ruby string algorithm