DEV Community

Cover image for If let shorthand project wide refactoring using Xcode regex search & replace.
Daniel Tavares
Daniel Tavares

Posted on

If let shorthand project wide refactoring using Xcode regex search & replace.

Swift 5.7 introduced this beauty (if let shorthand)
https://github.com/apple/swift-evolution/blob/main/proposals/0345-if-let-shorthand.md

You can leverage the power of regex in Xcode search and replace bar to refactor your projects codebase.

Search:

if let (\w+) = (\1) \{

Replace:

if let $1 \{

Xcode Regex Search & Replace

Discussion (0)