Skip to content

Instantly share code, notes, and snippets.

@jeanbaptistebeck
Last active January 28, 2016 14:49
Show Gist options
  • Save jeanbaptistebeck/ba3b5d545adb1e6d81d7 to your computer and use it in GitHub Desktop.
Save jeanbaptistebeck/ba3b5d545adb1e6d81d7 to your computer and use it in GitHub Desktop.
require 'verbal_expressions'
tester = VerEx.new do
start_of_line
find 'http'
maybe 's'
find '://'
maybe 'www.'
anything_but ' '
end_of_line
end
url = "https://www.brandandcelebrities.com"
puts 'Ca marche bien' if tester.match(test_url)
puts 'Ca marche aussi !' if tester =~ test_url
#Afficher la regex
puts tester.source # => /^(http)(s)?(\:\/\/)(www\.)?([^\ ]*)$/
#####
scope :scope, -> { where(created_at: first.created_at..last.created_at)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment