Tuesday, 15 April 2014

regex - Different result for Regexp match with Rails and Rubular? -



regex - Different result for Regexp match with Rails and Rubular? -

i using rails 4.0.0 ruby 2.0.0 p247. writing url regexp matcher have no thought why not work:

2.0.0-p247 :033 > regexp = %r{\ahttps:\/\/#{ rails.configuration.aws[:bucket] }\.s3(-#{rails.configuration.aws[:region]}|)\.amazonaws\.com\/(?<path>uploads\/.+\/(?<filename>.+))\?.+\z}.freeze => /\ahttps:\/\/test-gem\.s3(-eu-west-1|)\.amazonaws\.com\/(?<path>uploads\/.+\/(?<filename>.+))\?.+\z/ 2.0.0-p247 :034 > url = "https://test-gem.s3.amazonaws.com/uploads/2alrg16mvx6r-29590d114fb3257846c1a03330418da9/3031674-poster-p-1-for-25.jpg" => "https://test-gem.s3.amazonaws.com/uploads/2alrg16mvx6r-29590d114fb3257846c1a03330418da9/3031674-poster-p-1-for-25.jpg" 2.0.0-p247 :035 > regexp.match(url) => nil

but when seek debug in things rubular, work. idea? thanks!

remove \?.+ in end if regexp

ruby-on-rails regex

No comments:

Post a Comment