Regex: String Replac­ement Cheat Sheet

$nnth non-pa­ssive group
$2“­xyz­” in /^(abc­(xy­z))$/
$1“­xyz­” in /^(?:a­bc)­(xyz)$/
$`Before matched string
$’After matched string
$+Last matched string
$&Entire matched string

Some regex implem­ent­ations use \ instead of $.

Leave a Reply

Your email address will not be published. Required fields are marked *