Regular expression cheatsheet

From braindump
Revision as of 20:59, 24 November 2015 by Uroesch (talk | contribs) (Created page with "{{DISPLAYTITLE:Regular expression cheatsheet}} This is small collection of regex that patterns I want to document because I think they are useful, at least for me. == Check...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


This is small collection of regex that patterns I want to document because I think they are useful, at least for me.

Check unknown values only

For a serverspec test I needed to write a check where all unknown shell aliases should match in one query without looping. This is what I came up with. I know that the 3 grep patterns could be further reduced.

^alias\s+(?!(?:egrep|fgrep|grep|which)=)

Which matches only the last 2 highlighted entries but not the leading 4 ones:

alias egrep=
alias grep=
alias fgrep=
alias which=
alias whatever=
alias foobar=