Skip to content

apeiros/silverplatter-wordex

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

WordEx

Summary

WordEx is a word based pattern matching library. It is similar to Regexp. But while Regexp matches individual characters, WordEx is built to match word sequences.

Demo cases

With a variable word

WordEx.new("I saw them playing :game yesterday").
     match("I saw them playing tennis yesterday")
# => {:game => "tennis"}

With a variable substring

WordEx.new("I saw them +doing yesterday").
     match("I saw them playing tennis yesterday")
# => {:doing=>"playing tennis"}

Automatic conversion

WordEx.new("I have :apple_count@Integer apples").
     match("I have 5 apples")
# => {:apple_count=>5}

Validation

WordEx.new("I have :apple_count@Integer apples").
     match("I have many apples")
# => nil

Enforce positive values

WordEx.new("I have :apple_count@+Integer apples").
     match("I have -5 apples")
# => nil

About

A word based pattern matcher

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages