Questions tagged [swift-string]

swift-string - use this tag only for questions about String type futures or problems in swift open-source programming language developed by Apple Inc.

25 questions
0
votes
1 answer

Convert between diacritic variants of a character

I'm passing a string as a parameter to command line tool written in swift. I have a problem with some characters containing diacritics. If I pass à á ả ã ạ й ё as a line argument, inside the app I got à á ả ã ạ й ё. It looks the same, but…
Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220
0
votes
0 answers

Why is my search string not found in a larger string if compared with Regular Expression?

I am trying to find a substring in another string. I am using Regular expressions. The code is as below: let occurrence = "Kingfisher:" let string = "Swiss: SW123123\nKingfisher: KF994455\nQuantus: QS12343\nJetAir: FF7865667\nThai: TH123442\nDelta:…
Rohan Bhale
  • 1,323
  • 1
  • 11
  • 29
0
votes
1 answer

how can i add extra spaces before any special character

how to add extra spaces before any Special character in string ,in Swift, for example if i have string var str = "#StackOverFlow@is$awesome" " #StackOverFlow @is $awesome" // i have to achieve this...add empty spaces before every # how can…
developer
  • 65
  • 4
0
votes
4 answers

How to force Swift to recognize apostrophe?

I am trying to replace all apostrophe (') characters in a string with another character. I am running this code: someString.replacingOccurrences(of: apost, with: "a") I have tried to let apost equal the following: apost = "\'" apost = #"'"# apost =…
0
votes
0 answers

How to concat two unicodes in Swift

I have following two unicodes let countryFlag1 = "0x1F1E6" let countryFlag2 = "0x1F1E9" How to concat two unicodes to and assign it to textfield Tried following it is working but don't know how to do it with variable as there can be multiple…
amodkanthe
  • 4,345
  • 6
  • 36
  • 77
0
votes
2 answers

Swift replace occurrence of string with condition

I have string like below

I am a strongPerson

I want to covert this string like this

I am a weakPerson

When I try below code let old = "

I am a strongPerson

" let new =…
Mani murugan
  • 1,792
  • 2
  • 17
  • 32
0
votes
3 answers

Getting "String.Index" while enumerating swift string

Currently we iterate string as below: let greeting = "Hello" for (intIndex, char) in greeting.enumerated() { let currentIndex = greeting.index(greeting.startIndex, offsetBy: intIndex) let indexAfterCurrentIndex = greeting.index(after:…
Faisal Ikwal
  • 703
  • 3
  • 8
  • 25
0
votes
3 answers

How to convert Strings in Swift?

I've two cases where I need to convert strings to different formats. for ex: case 1: string inputs: abc, xyz, mno, & llr // All Strings from a dictionary output: ["abc","xyz", "mno", "llr"] //I need to get the String array like this. But…
Group
  • 325
  • 1
  • 4
  • 16
-1
votes
2 answers

how to remove character when backspace is pressed swift

i want to remove one last character when user presses the backspace func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { if string.isEmpty { …
Wahid Tariq
  • 159
  • 10
-1
votes
1 answer

Convert array of custom object to String in swift4

I am new to Swift and have an issue converting an array of custom object, to String. This is my response class Tickets public struct Tickets: Codable { public let name: String! public let status: String! public let…
Naren
  • 115
  • 2
  • 14
1
2