Engrain by ByteRush

JS.09.02 Mid-level

Groups, lookarounds and Unicode + Regex safety and when not to use regex

Comes up in: JavaScript, Coding

This concept is being written. It gets the full five steps — explanation, predict, interview angle, practice with tests, and review cards. Here is exactly what it will cover, so you can study it elsewhere in the meantime.

What it covers

  • named groups
  • backreferences
  • lookahead/lookbehind
  • Unicode property escapes \p{L}
  • v flag set operations
  • lastIndex with g/y trap
  • catastrophic backtracking (ReDoS)
  • nested quantifiers
  • do not parse HTML/emails fully with regex
  • prefer URL, URLSearchParams, parsers

Words you will know

lookaheadlookbehindnamed groupUnicode property escapebacktrackingReDoS

What you will practise

  • parse log lines
  • password rules
  • find and fix a ReDoS pattern

Interview questions this answers

  • What is ReDoS and how do you avoid it?