0.0.3 • Published 6 years ago
like-to-regexp v0.0.3
like-to-regexp
Transform sql like query to a valide regexp.
SQL LIKE | ReGexp |
---|---|
value | /^value$/i |
%value% | /^.value.$/i |
value% | /^value.*$/i |
%value | /^.*value$/i |
v_lue | /^v.lue$/i |
Install
yarn add like-to-regexp
Usage
import toReGexp from 'like-to-regexp'
const regexp = toReGexp('%value%')
if (regexp.test('value')) console.log('Hello world')