Skip to main content

wildstring

I needed a wildcard processing tool for an application I was working on.  I didn't want to use regular expressions, because the wildcard values were going in a configuration file, and regex would basically render them unreadable.  So I looked around for a wildcard library for JS and couldn't find a decent one.  In fact, when people asked for one, they generally were told "Learn Regular Expressions".  While I completely agree that knowledge of regular expressions is an incredible boon to a programming career, my response to a problem is not to tell someone it can't be solved, so I wrote a library of may own

Introducing wildstring

wildstring does simple wildcard processing without any dependencies.  It works both on the client and in the server, so you can use it anywhere.  wildstring handles wildcard string processing simply.  Here are some examples

wildstring.match('Wild*', 'Wild Thing'); // returns true, because ' Thing' is matched by '*'
wildstring.replace('You make my heart *', 'string'); // returns 'You make my heart string' because * is replaced with string
wildstring.replace('You * everything *', [ 'make', 'groovy' ]); // returns 'You make everything groovy' because 'make' replaces the first * and 'groovy' replaces the second

It can also accept alternative wildcards.
wildstring.wildcard = '||';
wildstring.match("I || you", "I think I love you"); // true
wildstring.replace("You make my heart ||", "string"); // "You make my heart string"
And you can tell wildstring to ignore case when matching
wildstring.caseSensitive = false;
wildstring.match("Wild *", "wILD tHING"); // true

Comments

Popular posts from this blog

How to identify a skilled programmer during an interview

How does one identify a skilled programmer?  No company that has interviewed me could tell the difference between myself and other programmers they'd interview.  The interview process is truly a game of luck in this industry--on both sides.  Both the programmer and the company are basing their actions entirely on luck.

Companies have come up with numerous methods to attempt to discern a good programmer from a bad one.  The best tricks they have include a series of math problems, algorithms, problem solving technique tests, and even obscure programming questions, some without definitive answers.  As an example: Is there an authoritative source of information on the core principles that define object oriented programming?  I've heard everywhere from 3 to 7.  In a field of research about a synthetic concept, an authoritative answer is almost impossible to obtain.

Programmers were then forced to study to the interview.  Careercup is one of my favorite sites for this.  This almost …

When Is Software Done?

I have some very exciting news.  A piece of software I've been working on for over 2 years is released to the general public!  This is a little exciting if it were software I'd been working on for some big company.  It's very exciting because it's software I have been working on for my company.  That's right!  My company is ready to start selling software and start making money!

I'm not gonna use this blog post to talk about my company and what it does.  You can read about that in our press release.  Instead, I'm going to talk about the software industry and the concept of done.  Because, as with everything, it's more complicated than it seems.

Software is never really done
Actually that's a misnomer.  Software can really be done.  But done is sort of a quantum state--there and not there at the same time.  First and foremost, anyone can understand that software that works is complete.  If the software's purpose is to process a credit card, if th…

Managing Programmers

Working with other programmers is tricky.  That said, it's nothing compared to the job of managing programmers.  One of my favorite quotes about Perl is that (paraphrased) "a Perl developer is like a rockstar.  Now imaging having a bunch of rockstars in one room together and you will understand why you don't want an entire team of Perl developers."  It's not about Perl here though. What's important to understand is that any developer worth his salt is going to be like a rockstar.  And yes, there are a lot of professional developers out there who aren't worth their salt, but that's for another post another day.  Rockstar may not be the right term here, but think of it this way.  These guys are smart.  They may not be geniuses, but there's going to be things that they know that you don't and probably never will.

I've seen it more than once and it's not going to make some Product Managers happy, but I'm going to state a fact, an eleph…