Sort by

recency

|

219 Discussions

|

  • + 0 comments

    return /^(Mr|Mrs|Ms|Dr|Er).[a-zA-Z]+$/;

  • + 0 comments

    let re = /^[MDE][rs]+[back slash here.][A-Za-z]+$/;

    let re = /^(Mr|Mrs|Ms|Dr|Er)[.][A-Za-z]+$/;

  • + 0 comments

    const re = new RegExp('^(Mr.|Mrs.|Ms.|Dr.|Er.)[A-Za-z]+$');

    Wrong Answer :( Input (stdin) Dr#Joseph Your Output (stdout) true Expected Output false

  • + 0 comments

    let re = /^(Mr.|Mrs.|Dr.|Er.)[a-zA-Z]+$/g`

  • + 1 comment

    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.