• + 0 comments

    Something a bit different:

    function regexVar() {
        const re = new RegExp(/^[MEDR][rs]{1,2}\.[a-zA-Z]+$/)
        return re;
    }
    
    • ‘^’ match at beginning of string
    • ‘[MEDR]’ any of these letters
    • ‘[rs]’ followed by one of these letters
    • \{1,2}’ repeated between 1 and two times.
    • ‘.’ followed by period (escaped char.)
    • ‘[a-zA-Z]+’ then one or more upper or lowercase letters
    • ‘$” at then end of the string (nothing after)