John Siu Blog

Tech - Business Tool, Personal Toys

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]*

Match ](/), while ... don’e contain )# and link not closed with /.

](/blog/test) : Not match

](/blog/test/) : Match

\]\(/[^/][^)#]*[^/]\)

John Siu

Update: 2020-10-15
comments powered by Disqus