Skip to content

Instantly share code, notes, and snippets.

@jhildensperger
Created November 12, 2015 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhildensperger/673cfa62c64e61143375 to your computer and use it in GitHub Desktop.
Save jhildensperger/673cfa62c64e61143375 to your computer and use it in GitHub Desktop.
Regular expressions to fix Swift formatting
// (optionalType?.nonOptionalType)! -> optionalType!.nonOptionalType
// find
\((\w+)\?\(.\w+)\)\!
// replace
$1!$2
// poorly formatted if statements
// find
if\s*\(\s*(.*\b)\s*\)\s*{
// replace
if $1 {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment