Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

search-string demo

node v8.17.0
version: 2.0.0
endpointsharetweet
const SearchString = require("search-string") // All pizzas to me NOT from jane topped with cheese and NOT mushrooms. :) const str = 'to:me -from:jane@mixmax.com pizza topping:cheese -topping:mushrooms' // Parse string into SearchString object. const searchString = SearchString.parse(str); // Add another topping choise. In this case: NOT onions. searchString.addEntry('topping', 'onion', true /* negated */); // Get results into an array format: /* [{"keyword":"to","value":"me","negated":false},{"keyword":"from","value":"jane@mixmax.com","negated":true},{"keyword":"topping","value":"cheese","negated":false},{"keyword":"topping","value":"-mushrooms","negated":false},{"keyword":"topping","value":"onion","negated":true}] */ searchString.getConditionArray(); // Get results back into a human readable string. Useful for passing to APIs. // to:me -from:jane@mixmax.com topping:cheese -topping:mushrooms,onion pizza searchString.toString();
Loading…

no comments

    sign in to comment