Skip to content

Instantly share code, notes, and snippets.

@jeremypage
Last active July 8, 2025 08:24
Show Gist options
  • Save jeremypage/addf2e9c9715325b629de3df16787271 to your computer and use it in GitHub Desktop.
Save jeremypage/addf2e9c9715325b629de3df16787271 to your computer and use it in GitHub Desktop.
Regex cheatsheet

Regex cheatsheet

UK National Insurance Number

^[a-zA-Z]{2}(?:\s*\d\s*){6}[a-zA-Z]?\s*$

HTML: Demote all (second) duplicate H1 tags to H2

Search

((<h1>[^<]*<\/h1>)(.|\s)+?)<h1>([^<]*)<\/h1>

Replace

$1<h2>$4</h2>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment