Joker – Ruby gem

September 10, 2009

Joker – Ruby gem

Good Alternate for Regular expressions

require ‘rubygems’
require ‘joker’

wild = Wildcard['Fairy?ake*']

puts wild =~ ‘Fairycake’                     #=> true
puts wild =~ ‘Fairyfakes’                    #=> true
puts wild =~ ‘Fairylake is a cool place’     #=> true

puts wild =~ ‘Dairycake’                     #=> false
puts wild =~ ‘Fairysteakes’                  #=> false
puts wild =~ ‘fairycake’                     #=> false

puts wildi = Wildcard['Fairy?ake*\?', true]

puts wildi =~ ‘FairyCake?’                   #=> true
puts wildi =~ ‘fairyfakes?’                  #=> true
puts wildi =~ ‘FairyLake IS A COOL Place?’   #=> true

Wildcard.quote(‘*?\\’)                  #=> ‘\\*\\?\\\\’

For more details about this gem –> http://bit.ly/L9kcg

Leave a Reply