/.* # Stuff ( # START capturing to $1 \ # exactly 1 space | # OR \[* # 0 or more [s \w* # 0 or more word characters \@* # 0 or more @s \-* # 0 or more -s \w* # more word characters [$\#\%>~] # exactly 1 of $, #, %, > or ~ \]* # 0 or more ]s | # OR \\\[\\e\[0m\\\]\ \[0m # the sequence: \[\e[0m\\] [0m ) # END of $1 \s? # 0 or 1 spaces /x