Regex Cheat Sheet
☰ Table of Content
Some regex I used.
IPv4
Match IPv4 in digit:
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
Match IPv4 in alphanumeric:
\w{1,3}\.\w{1,3}\.\w{1,3}\.\w{1,3}
URL
With http/https
https?://[^\[\]()\s]*
Optional http/https
(https?:)?//[^\[\]()\s]*
Internal link
/[^/][^\[\]()\s]*
Markdown link not close with /
Match ](/
…)
, while ...
don’e contain )#
and link not closed with /
.
](/blog/test)
: Not match
](/blog/test/)
: Match
\]\(/[^/][^)#]*[^/]\)
Replace 1 but not 2 consecutive characters
General form:
(?<!x)x(?!x)
Match 1 newline but not 2 in a row:
(?<!\n)\n(?!\n)
Match 1 newline but not 2 in a row and also not following a .
or "
:
(?<!(\n|”|"|\.))\n(?!\n)
John Siu
Update: 2025-07-21
Tag
[Regex]