Sort by

recency

|

216 Discussions

|

  • + 0 comments

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

  • + 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.

  • + 0 comments
      const re = /^(Mr|Mrs|Ms|Dr|Er)\.[a-zA-Z]+$/;
      return re;
    }
    
  • + 0 comments

    const re = /^([^.^\s].){1}[^.]$/

    const re = / ^ ( open_square_brackets ^ backslash . ^ backslash s closed_square_brackets * backslash . ) { 1 } open_square_brackets ^ backslash . closed_square_brackets * $ /

    Start pattern has (anything except a dot or space, then a dot.). Start pattern repeats once. After that anything except a dot.

    The backslashes do not show up correctly inside the square brackets so the pattern is written above with text.

  • + 0 comments
    let re = /^(M(r|s|rs)|([DE]r))\.[A-Za-z]+$/;
    

    this handels all the chases require which the top ones dont take into account like "Msr.abc"or "Ds.abc"