Useful Regexes

This contains various regexes that I find useful.

Match any character except newline

.

Match first word of a string on multiple lines

/(word1|word2|word3)/igm

Multiple lines of neg and pos floating point numbers that are less than 1000

/^-?\d{1,3}\.\d+$/igm

Do not return result from a group

(?:)

For example, do not return the year from this string:
12/06/2016 05:52

(^\d{2}\/\d{2}\/(?:2015|2016) (\d{2}:\d{2})$)

You'll note that everything else is being captured, as well as the time being caputured by a specific group. However, this will not include 2015 or 2016.

Doesn't start with http

/^((?!http).)*$/

Resource: https://stackoverflow.com/questions/406230/regular-expression-to-match-a-line-that-doesnt-contain-a-word

Remove http(s) from every line

s/^http.?:\/\///g

Match 2 or 3 digits

^[0-9]{2,3}$

Resource: https://stackoverflow.com/questions/20537762/regex-to-match-d-or-e-followed-by-2-3-digits