Skip to content

Instantly share code, notes, and snippets.

@fstorr
Last active December 14, 2015 13:38
Show Gist options
  • Select an option

  • Save fstorr/5094689 to your computer and use it in GitHub Desktop.

Select an option

Save fstorr/5094689 to your computer and use it in GitHub Desktop.
Make brain hurt fewer
** Look arounds **
Positive lookahead: q(?=u) // find q followed by u
Negative lookahead: q(?!u) // find q not followed by u
Positive lookbehind: (?<=a)b // find b preceeded by a. CANNOT BE VARIBLE LENGTH
Negative lookbehind: (?<!a)b // find b not preceeded by a. CANNOT BE VARIBLE LENGTH
** Atomic grouping **
<!-- replace ' or ’ with HTML apostrophe -->
Find: (?<=\w)'|’(?=\w)
Replace: &#8217;
<!-- find repeated words -->
Find: \b([\w']+)\s\1
<!-- replace CSS #xxxxxx with #xxx -->
Find: #([\da-f])\1([\da-f])\2([\da-f])\3\b
Replace: #$1$2$3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment