@lou.codes/predicates
Version:
🧐 Predicate util functions
19 lines (18 loc) • 608 B
TypeScript
import type { RegularExpression } from "@lou.codes/types";
/**
* Given a regular expression and a string, returns `true` if the string matches the regular expression.
*
* @category Primitives
* @example
* ```typescript
* const matchNumbers = match(/\d+/u);
*
* matchNumbers("123"); // true
* matchNumbers("abc"); // false
* ```
* @param regularExpression Instance of `RegExp` or a string.
* @returns `true` if the string matches the regular expression, `false` otherwise.
*/
export declare const match: (
regularExpression: Readonly<RegExp> | RegularExpression,
) => (text: string) => boolean;