From: Carlos Camargo Date: 2011-07-23T03:42:30+09:00 Subject: Regexp inconsistency I observed a inconsistent behavior between ruby (ruby 1.8.6 (2009-06-08 patchlevel 369) [x86_64-linux]), running in my host, and ruby in www.rubular.com (reports "Rubular runs on Ruby 1.8.7."). The expression: / (\w+(\-\w+)?) \. (log|txt) [\.\-]? (\d{1}) ( \. (gz|bz2))? /x in my host returns (among others): net-snmpd.log-20110629.bz2 In rubular site, recognize (correctly, I suppose!) just until: net-snmpd.log-2 (stop here, i.e. don't recognize the string). Thanks for any help! (Upgrade ruby to 1.9 isn't an option!) Camargo NB: My code (just for test) is: #! /usr/bin/ruby -w require 'find' re_logdir = Regexp.new(/\/log$|\/log\/|\/logs$|\/logs\//) dias = 5 ### a='(\w+(\-\w+)?)' d='(\d{4}[\.\-]?\d{2}[\.\-]?\d{2})' h='(\d{2}[\.\-]?\d{2}[\.\-]?\d{2,6})' l='(log|txt)' z='(gz|bz2)' n1='(\d{1})' s='[\.\-]' re_logfile = Regexp.new(/ #{a} \. #{l} #{s}? #{n1} ( \. #{z})? /x ) p re_logfile Find.find('/') do |f| if File.file?(f) and re_logdir.match( File.dirname(f) ) and re_logfile.match( File.basename(f) ) p f end end -- Posted via http://www.ruby-forum.com/.