import { isNotNil } from '@angular-ru/cdk/utils';

const REG_EXP_STRICT_NAME = /^[,A-Z_a-z][\w,]*$/;
const REG_EXP_NO_CYRILLIC = /[^,А-я]+/g;
const REG_EXP_DIGITS_SEPARATED_BY_COMMA = /\d+(,\d+)*,?/g;
const REG_EXP_DIGITS = /\d*/g;
const REG_EXP_CREDIT_CARD_NUMBER_WITH_SEPARATOR = /^(?:\d{4}-){3}\d{4}$/g;
const REG_EXP_NUMBER = /^(\d+(\.\d+)?)$/;

function ensureRegexp(regexp) {
    let prepared = regexp.charAt(0) === '/' ? regexp.slice(1) : regexp;
    prepared = prepared.charAt(prepared.length - 1) === '/' ? prepared.slice(0, prepared.length - 1) : prepared;
    return prepared;
}

const MIN_SIZE_REGEXP = 2;
function isRegexpStr(value) {
    return ((value?.length ?? 0) > MIN_SIZE_REGEXP && value?.charAt(0) === '/' && value?.charAt(value?.length - 1) === '/');
}

function matchedByRegExp(regexp, value) {
    const matcher = regexp instanceof RegExp ? regexp : new RegExp(ensureRegexp(regexp), 'ig');
    return isNotNil(value.match(matcher)?.[0]);
}

/**
 * Generated bundle index. Do not edit.
 */

export { REG_EXP_CREDIT_CARD_NUMBER_WITH_SEPARATOR, REG_EXP_DIGITS, REG_EXP_DIGITS_SEPARATED_BY_COMMA, REG_EXP_NO_CYRILLIC, REG_EXP_NUMBER, REG_EXP_STRICT_NAME, ensureRegexp, isRegexpStr, matchedByRegExp };
//# sourceMappingURL=angular-ru-cdk-regexp.mjs.map
