const isValidRegExpCache = { } ; export function PCREToECMARegExp ( source ) { const groups = source . match ( /\?P\<[\w\d]+\>/gi ) ; if ( groups === null || groups . length === 0 ) { return source ; } Array . prototype . forEach . call ( groups , ( group ) => { source = source . replace ( group , group . replace ( '?P<' , '?<' ) ) ; } ) ; return source ; } export function isRegStrValid ( strRegExp , parameters = 'gi' ) { if ( typeof strRegExp !== 'string' ) { return false ; } const key = `__${ strRegExp }__` ; if ( isValidRegExpCache [ key ] !== void 0 ) { return isValidRegExpCache [ key ] ; } try { const regExp = new RegExp ( strRegExp , parameters ) ; if ( regExp instanceof RegExp ) { isValidRegExpCache [ key ] = true ; } } catch ( error ) { isValidRegExpCache [ key ] = false ; } return isValidRegExpCache [ key ] ; }