Regular Expressions 101

Sp⁠onsors

Community Library

Community Library Entry

0

Regular ExpressionOpen Workspace

/
(?:\s|^)([\-+]?)(?:(")([^"]+)"|(')([^']+)'|()(\S+))
/
gi

Description
Created·2014-11-17 13:52
Type·Match
Flavor·PCRE (Legacy)

A simple regexp to parse a search string.

It will split the search string into an array of search terms.

Each search term will be represented by an array containing 3 strings:

Index 0: A plus sign, minus sign or an empty string. You can use this to determine if the word is allowed, is not allowed or is reqiured to be matched.

Index 1: A single quote, double quote or an empty string. You can use this to identify quoted strings - "exact matches" - that should be given a higher relevance when matched.

Index 2: The word to match.

Submitted by @bananascript
Open Workspace