viniceosm
5/16/2018 - 2:43 PM

regex include and exclude

regex include and exclude

two pattern

let validate = (str) => {
    let required = /(\$.*\$)/i; // Regex include - tem que te-lo
    let blocked = /(\$\()/i; // Regex exclude - não tem que te-lo
    return required.test(str) && !blocked.test(str);
}

one pattern

let validate = (str) => {
    let one = /(?=.*(\$.*\$))(?!.*(\$\())(.+)/i;
    return one.test(str);
}