export const getSplitValueJoinByOr = ( value ) => value . split ( '' ) . join ( '|' ) ; export const getValueRegExp = ( value ) => { const joinedVal = getSplitValueJoinByOr ( value ) ; return new RegExp ( joinedVal , 'g' ) ; } ; function checkValuesMatched ( regValue , shouldMatchValue ) { const regValueLength = regValue . length ; const regExp = getValueRegExp ( regValue ) ; const matchResult = shouldMatchValue . match ( regExp ) ; const isAllMatchedByRegValue = matchResult && matchResult . length >= regValueLength ; return isAllMatchedByRegValue ; } export default checkValuesMatched ;