Joker – Ruby gem

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

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s