instead of dd, try \d\d
file.replace(/\d\d\-/, '')

in irb:

"12-test".match(/\d\d\-/)
=> #<MatchData "12-"> 




On Mon, 9 May 2011 22:45:29 +0900
flebber <flebber.crue / gmail.com> wrote:

> I am new too using regex on files and I am not quite getting the
> result I expect. The script currently doesn't error but also doesn't
> update the file either.
> 
> Trying to remove leading numbers and ' - 'from the start of a filename
> given a directory.
> 
> require 'fileutils'
> 
> def cleanFiles()
>   dir = 'C:\Users\RenshawFamily\maven\Music\Foo Fighters\Live At
> Wembley Stadium'
>   # add files to array unless a directoy is found
>   myFiles = Array.new << File.split(dir) unless File.file?("")
>   # Todo when files process step into directory and redo.
>   myFiles.each do|file|
>     # remove leading numbers a "-"
>     file.replace(/dd\-/, '')
>     Fileutils.mv(myFile, file)
>   end
> end
> 





-- 
http://spiralofhope.com