• + 0 comments

    The tests here dont cover a lot of overinclusion mistakes you could make with regex here. for instance, this regex will pass all tests: /^[MDE][rs]{1,2}\.[a-zA-Z]*$/ but this would also match "Ess", "Err", "Msr", Mss", "Mrr", etc. as well as the legitimate prefixes. A better pattern could be something like: /^(Mr?s|[MDE]r)\.[a-zA-Z]*$/ you could also or together each possible prefix, which would be less performant but more readable, which could be preferrable if optimization isn't needed.