Meta Chars Summary

Features Char Meaning
Classes . Any Char Except New Line
\d Digit (0-9)
\D Not a Digit (0-9)
\w Word Char (a-z, A-Z, 0-9, _)
\W Not a Word Char
\s Whitespace (space, tab, newline)
\S Not a Whitespace
Anchors ^ Beginning of a line
$ Ending of a line
\b Word Boundary
\B Not a Word Boundary
Range [abc] Chars in Range (a or b or c)
[^abc] Chars NOT in Range (a or b or c)
[a-q] Continuous Chars from a, b, q.
[1-7] Continuous Number from 1,2, 7.
Group (abc) As a Group
| Either or, often within a group (..|..|..)
Quantifiers * 0 or More times
+ 1 or More times
? 0 or One time
{n} Exact n times
{m,n} Between m and n times
Matching Parts $0 the whole matching parts
$n the n'th matching part

Example Code

vi data.txt

# vscode, using $n for n'th group
replace (https?)(:\/\/)(www\.)?(\w+)(\.\w+) with https$2$4$5

# bash, using \n for n'th group
sed -r 's/(https?)(:\/\/)(www\.)?(\w+)(\.\w+)/\https\2\4\5/g' data.txt