All files generateRegex.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18      1x 11x   11x                      
import { regexCharacters } from './regexCharacters'
import type { GenerateRegex } from './types'
 
export const generateRegex: GenerateRegex = regex => {
  const [open, close] = regexCharacters[regex]
 
  return {
    TEXT_WITH_BRACKETS: new RegExp(
      `(\\${open}\\${open}.+?\\${close}\\${close})`,
    ),
    TEXT_AMONG_BRACKETS: new RegExp(
      `\\${open}\\${open}(.*)\\${close}\\${close}`,
    ),
    KEY_VALUE_TEXT: /^[A-Za-z]([,\w]+)?=.+/,
    KEY_VALUE_NUMBER: /^[^0,]([,\d]+)?=.+/,
  }
}