0

is there any way where I can use AWK like commands or anything to directly convert for example this base text

import Foundation

class Constants {
  titleAboutUs
  titleBill
  titleCart
  titleContact
  titleDelivery
  titleDineIn
  titleFAQ
  titleMenu
  titleNotification
  titlePoints
  titleProfile
  titleShare
  titleTakeAway
}

to this target text

import Foundation

class Constants {
    let titleAboutUs = "titleAboutUs"
    let titleBill = "titleBill"
    let titleCart = "titleCart"
    let titleContact = "titleContact"
    let titleDelivery = "titleDelivery"
    let titleDineIn = "titleDineIn"
    let titleFAQ = "titleFAQ"
    let titleMenu = "titleMenu"
    let titleNotification = "titleNotification"
    let titlePoints = "titlePoints"
    let titleProfile = "titleProfile"
    let titleShare = "titleShare"
    let titleTakeAway = "titleTakeAway"
}

EDIT

I know how to use SED and AWK, but I wish I can do it directly in XCode, first version of XCode was created many years ago, why they don't have a visual way to process text like this? my question is, is their any plugin to have a visual way to do this directly in XCode IDE?

I just knew about vertical selection (that is done with alt key), I have never seen some good article that talk about these stuff.

Cyrus
  • 84,225
  • 14
  • 89
  • 153
DeyaEldeen
  • 10,847
  • 10
  • 42
  • 75
  • 1
    The goal is that you add some code of your own to your question to show at least the research effort you made to solve this yourself. – Cyrus Jun 23 '18 at 21:26

1 Answers1

2

Xcode has, for quite some time, supported regular expression find and replace. From the Find menu, select Find and Replace. Click the magnifying glass icon in the search pattern field and select Edit Find Options. In the resulting pop-up window, change the Matching Style from Textual to Regular Expression.

I did the transform you wanted by using a search pattern of ^ (\w+)$ and a replacement of let $1 = "$1".

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154