Skip to content

regex cheat sheet

Regex CheatSheet

Anything that Line starts with abc and Line ends with xyz

^abc.*xyz$
^abc(.*)xyz$

Anywhere anything between ABC and xyx & includes abc and xyz

abc.*xyz
abc(.*)xyz

Find pattern between multiple lines

abc((.|\n)*)xyx

Find pattern between multiple lines

Regex pattern to find

abc((.|\n)*)lmn((.|\n)*)xyz
Regex pattern to replace. Each pattern corresponds to equivalent $n
def$1opq$2wxy

Make Regex non-greedy, select only the first occurence

abc((.|\n)*?)lmn
abc(.*?)xyz