npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wildstring

v1.0.9

Published

Simple String Wildcard Handling

Downloads

42,534

Readme

wildstring

Simple String Wildcard Handling

build status npm version Codacy Badge Code Climate bitHound Score Join the chat at https://gitter.im/deltreey/wildstring

Shake it shake it

Installing wildstring is a snap. wildstring has no dependencies, so you don't need anything else to run it. If you want to use tools though, here's some tips on how to install it with popular installers.

node.js

npm install wildstring

then:

var wildstring = require('wildstring');

bower

bower install wildstring

html

<script src="wildstring.js"></script>

Hold me tight

Especially with something that does something new, it's important to see how it works. Below are some examples, but here's a brief explanation as well.

In this explanation, I'll use * as my wildcard for simplicity. If you put a wildcard at the beginning, for example *Thing then you can match anything or nothing before your string. So your string could be Wild Thing or just Thing and it would match fine. The same is true for the end. Wild* would match Wild Thing or just Wild. If you want to match text in the middle of the string, it works the same way. Wild*Thing matches both WildThing and Wild and crazy Thing.

wildstring.match('Test*', 'Testing');                 // true, wildcard matches 'ing'
wildstring.match('*ing', 'testing');                  // true, wildcard matches 'test'
wildstring.match('Test*', 'Test');                    // true, wildcard can match empty strings
wildstring.match('*ing', 'Testing it');               // false, no wildcard do match ' it'
wildstring.match('Test', 'Testing');                  // false, no wildcard to match 'ing'
wildstring.match('Test*ing', 'Testing this thing');   // true, matches 'Test' and the end of 'thing', the rest is wildcard matched
wildstring.match('*))))))*', ')))))');                // false, not enough parenthesis

You make my heart string

You can use wildstring for string interpolation, which makes for an easier interface to parse data from users who maybe don't know regular expressions.

wildstring.replace('I * node.*', [ 'love', 'js' ]);   // 'I love node.js'
wildstring.replace('I * node.*', 'script');           // 'I script node.script' * this behavior is the same as "I * node.*".replace("*", "script") and actually uses that method
wildstring.replace('I * node.*', [ 'love' ]);         // THROWS AN ERROR, wildcard count and number of strings to insert must match
wildstring.replace('*/*/*', [ new Date.getMonth() + 1, new Date.getDate(), new Date.getFullYear]);
// 7/15/2015 (or whatever day it is), probably better to learn the js date parser though

You make everything, groovy

You can use your own wildcards with wildstring, so you can wildstring everything. You can even turn off case sensitive matching if you want.

wildstring.wildcard = 'stuff';
wildstring.match('Test stuff', 'Test wild');            // true, wildcard 'stuff' matches 'wild'
wildstring.replace('stuff and stuffthings', [ 'WILD', 'thing' ]); // 'WILD and thingthings'
// turn off case sensitive matching
wildstring.caseSensitive = false;
wildstring.match('tEsT', 'TeSt');                       // true, 'test' matches 'test'

I think I love you

If you want to contribute to wildstring, it's really easy. Just make sure you have nodejs installed and do the following.

git clone https://github.com/deltreey/wildstring
# npm install -g grunt-cli # if you don't have it
npm install
grunt

grunt will run all the tests and jshint, so just make sure it passes before submitting a pull request

But I wanna know for sure

Documentation: http://deltreey.github.io/wildstring

Repository: https://github.com/deltreey/wildstring