Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
Simple regex question.
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Robert Klemme, post: 4642729"] Combining all the good suggestions this is probably what I'd do: files =3D Dir.glob("L:/infocontiffs/ehs-g7917741/*.tiff") files.each do |f| base =3D File.basename f root =3D base[/^([^_]+)_\d+\.tiff$/, 1] if base # rename or whatever else $stderr.puts "Dunno what to do with #{f}" end end The reason I left in the matching of underscores and digits is to be sure that the complete name matches the pattern that we required in order to detect other files that might accidentally have been placed in that directory. Kind regards robert --=20 remember.guy do |as, often| as.you_can - without end [URL]http://blog.rubybestpractices.com/[/URL] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
Simple regex question.
Top