Regex-fu

Keep only ports number

From rustscan output, keep only the port numbers and concatenate it with commas. Useful to perform more in depth scan with nmap with only open ports.

cat rustscan.txt | grep -Pio '[0-9]{1,}(?=\/(tcp|udp)[ ]*open)' | sort -u | tr '\n' ,

Selecting all IPV4 address format

alias grep-ip='grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"'

Tools

Very useful tool when testing regex. The tool takes your text and regex tells you what part of your input text match the regular expression you wrote. Give also indications about what your regex do.

Selecting format {f}{last}

Cherche un nombre de lettre X [a-z|A-Z]* suivi par un espace [ ] qui est précédé par quelque chose qui commence par une lettre (?<=^[a-zA-Z])

(?<=^[a-zA-Z])[a-z|A-Z]*[ ]

Ressources

Learn Regex in 20 minutes. Very easy and comprehensive tutorial to be able to craft most of the regex we need.

Colt Steele Regex Bootcamp

Last updated