UNPKG

ts-regex-builder

Version:

Maintainable regular expressions for TypeScript and JavaScript.

1 lines 967 B
{"version":3,"file":"lookbehind.mjs","names":["encode","lookbehind","sequence","precedence","pattern"],"sources":["../../../src/constructs/lookbehind.ts"],"sourcesContent":["import { encode } from '../encoder';\nimport type { EncodedRegex, RegexSequence } from '../types';\n\n/**\n * Positive lookbehind assertion.\n *\n * A positive lookbehind assertion is a zero-width assertion that matches a group of characters only if it is preceded by a specific group of characters.\n *\n * @example\n * ```ts\n * lookbehind(\"a\");\n * // /(?<=a)/\n *\n * lookbehind([\"a\", \"b\", \"c\"]);\n * // /(?<=abc)/\n * ```\n */\nexport function lookbehind(sequence: RegexSequence): EncodedRegex {\n return {\n precedence: 'atom',\n pattern: `(?<=${encode(sequence).pattern})`,\n };\n}\n"],"mappings":"SAASA,MAAM;AAiBf,OAAO,SAASC,UAAUA,CAACC,QAAuB,EAAgB;EAChE,OAAO;IACLC,UAAU,EAAE,MAAM;IAClBC,OAAO,EAAG,OAAMJ,MAAM,CAACE,QAAQ,CAAC,CAACE,OAAQ;EAC3C,CAAC;AACH","ignoreList":[]}