[ANN] Joker -- Wildcards for Ruby

Discussion in 'Ruby' started by Fabian Streitel, Sep 9, 2009.

  1. [Note: parts of this message were removed to make it a legal post.]

    Hi folks,
    I'm proudly presenting:

    # Joker #

    http://karottenreibe.github.com/joker

    Joker is a Wildcard implementation for Ruby.

    ## Features ##

    * Behaves much like Regexp
    * ` * ` and ` ? ` as wildcard characters
    * ` \ ` for escaping
    * `\a` matches `\a`, but not `a`
    * Wildcards must always match whole string
    * Wildcards can be case insensitive

    Visit the website to see a small example etc.

    Greetz!
    Fabian Streitel, Sep 9, 2009
    #1
    1. Advertising

  2. On Sep 9, 2009, at 12:55 PM, Fabian Streitel wrote:

    > I'm proudly presenting:
    >
    > # Joker #
    >
    > http://karottenreibe.github.com/joker
    >
    > Joker is a Wildcard implementation for Ruby.
    >
    > ## Features ##
    >
    > * Behaves much like Regexp
    > * ` * ` and ` ? ` as wildcard characters
    > * ` \ ` for escaping
    > * `\a` matches `\a`, but not `a`
    > * Wildcards must always match whole string
    > * Wildcards can be case insensitive


    Can you suggest why someone would use this instead of a regular
    expression?

    James Edward Gray II
    James Edward Gray II, Sep 9, 2009
    #2
    1. Advertising

  3. [Note: parts of this message were removed to make it a legal post.]

    because "non-computer people" :)-) might find wildcards more easily
    understandable than regular expressions.

    This is of course not meant as a replacement for regexps when you're
    writing code but rather as a way to interface with people who don't
    know about regexps

    think directory listings, search queries etc.

    Greetz!

    2009/9/9 James Edward Gray II <>

    > On Sep 9, 2009, at 12:55 PM, Fabian Streitel wrote:
    >
    >
    > Can you suggest why someone would use this instead of a regular expression?
    >
    > James Edward Gray II
    >
    >
    >
    Fabian Streitel, Sep 9, 2009
    #3
  4. [Note: parts of this message were removed to make it a legal post.]

    > Note that these are known as "glob patterns" -- you might want to update
    > your documentation accordingly (http://en.wikipedia.org/wiki/Glob_pattern)
    >


    Ah, thx, I've been searching for the correct name of these but couldn't find
    it.
    The only thing I've ever heard was "Wildcard".


    >
    > Also, your rdocs seem to be missing a few backslashes:
    >
    > * '?' matches a single character
    > * '*' matches any number of characters, including 0
    > (1) * '*' matches a literal '*'
    > * '\?' matches a literal '?'
    > (2) * '\' matches a literal '\'
    >
    > 1 should be: '\*' matches a literal '*'
    > 2 should be: '\\' matches a literal '\'
    >
    > You could generalize by saying:
    > * '\x' matches the literal character 'x', even if 'x' is a wildcard
    > character.
    >


    I'll do that.


    >
    > You haven't implemented bracket expressions: '[cb]at*' should match
    > 'catch' and 'batch' but not 'match'
    >


    I'll look into that.

    Thanks for the feedback!
    Fabian Streitel, Sep 10, 2009
    #4
  5. [Note: parts of this message were removed to make it a legal post.]

    Whoops overlooked one:

    You could generalize by saying:
    > * '\x' matches the literal character 'x', even if 'x' is a wildcard
    > character.
    >
    >

    That's exactly not what my implementation does. Since I had the library in
    mind as
    a way to interact with users who don't know about Regular Expressions, I
    wanted
    to keep it as simple as possible.

    Thus, the Ruby String "fo\\o" fed to the Wildcard class would be equivalent
    to /^fo\\o$/
    but I'm not sure if that was a wise decision. The reasoning behind it was,
    that users woudn't
    have to type things like
    C:\\foo\\bar\\goo
    but rather only
    C:\foo\bar\goo
    since f b and g are no special characters.

    Does that make sense? What do you think? Which approach to take or should
    there be an option
    and if so what's the wiser default?
    Greetz!
    Fabian Streitel, Sep 10, 2009
    #5
  6. Just a thought... ruby already has globbing functions in dir.c, but they
    apparently work only on dirs. Maybe they could be abstracted in to a
    library that works on strings or arrays of strings.

    --
    vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
    Joel VanderWerf, Sep 10, 2009
    #6
  7. [Note: parts of this message were removed to make it a legal post.]

    >
    > Just a thought... ruby already has globbing functions in dir.c, but they
    > apparently work only on dirs. Maybe they could be abstracted in to a library
    > that works on strings or arrays of strings.
    >
    >


    Honestly: I have no idea what's going on in that file...
    That's just too complicated C magic whuzzing around in there.

    But a problem with that approach -- as far as I can tell -- is that
    matching a glob against a string and matching it against the
    file system are 2 different things. Especially since "/" or "\" have
    special meaning in file systems and allow for splitting of the glob
    string into small subsections, whose matching against files is much
    easier.
    Also dir.c has the special "**" glob, which doesn't make and sense
    in string matching.

    Greetz!
    Fabian Streitel, Sep 11, 2009
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas F. O'Connell

    Negative Lookbehind and Wildcards

    Thomas F. O'Connell, Feb 27, 2004, in forum: Perl
    Replies:
    1
    Views:
    721
    Gunnar Hjalmarsson
    Feb 28, 2004
  2. DotNetJunkies User

    DataView filters with wildcards

    DotNetJunkies User, May 24, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    548
    DotNetJunkies User
    May 24, 2004
  3. msnews.microsoft.com
    Replies:
    0
    Views:
    1,150
    msnews.microsoft.com
    Jul 18, 2004
  4. Josh Martin
    Replies:
    6
    Views:
    1,858
    Josh Martin
    Nov 23, 2003
  5. Fabian Streitel

    [ANN] joker-1.0.0

    Fabian Streitel, Oct 15, 2009, in forum: Ruby
    Replies:
    2
    Views:
    90
    Fabian Streitel
    Oct 16, 2009
Loading...

Share This Page