Linked Questions

35 questions linked to/from How does String substring work in Swift
-3 votes
2 answers
3k views

I have following Obj-c statement: string = [string substringFromIndex:(range.location + range.length)]; What it's Swift equivalent?
Alexey K's user avatar
  • 6,743
0 votes
1 answer
639 views

I checked lots of similar questions here, the answers to which do not seem to be a working solution for me. I am reading a formatted File into a string "Substring #1: Hello World!; Substring #2: My ...
Gasper J.'s user avatar
  • 523
0 votes
1 answer
135 views

How do I substring a string in swift 4. I would like to convert: "Hello, World!" Into: "Hello"
1 vote
1 answer
47 views

this function is supposed to just get a substring but I can't seem to quite get it. I've tried pretty much all combinations of types but nothing seems to work Code Causing the error: let final = temp....
Rshelver's user avatar
517 votes
48 answers
458k views

How can I get the nth character of a string? I tried bracket([]) accessor with no luck. var string = "Hello, world!" var firstChar = string[0] // Throws error ERROR: 'subscript' is unavailable: ...
129 votes
10 answers
163k views

In Objective-c we create range by using NSRange NSRange range; So how to create range in Swift?
vichhai's user avatar
  • 2,568
114 votes
11 answers
151k views

I'm used to do this in JavaScript: var domains = "abcde".substring(0, "abcde".indexOf("cd")) // Returns "ab" Swift doesn't have this function, how to do something similar?
156 votes
5 answers
171k views

I've been updating some of my old code and answers with Swift 3 but when I got to Swift Strings and Indexing it has been a pain to understand things. Specifically I was trying the following: let ...
Suragch's user avatar
  • 516k
85 votes
9 answers
64k views

In Swift 4, I'm getting this error when I try to take a Substring of a String using subscript syntax. 'subscript' is unavailable: cannot subscript String with a CountableClosedRange, see the ...
7 votes
4 answers
17k views

I'm trying to set a limit in my label to 10 characters, I'm a complete newbie to programming in general so its my 3rd month so far... anyway thanks in advance :-)
4 votes
3 answers
13k views

I know we can use subscript to cut a part of the string in Swift 4, . let s = "aString" let subS = s[..<s.endIndex] But the problem is, how to cut the s to a subString like aStr. I mean, What I ...
JsW's user avatar
  • 1,766
4 votes
6 answers
14k views

In my app I am receiving some incoming data from a web service. In that data some wrong values can also be received like new line characters. I want to find in response string that if it contains a ...
7 votes
4 answers
3k views

I get error in the last line when I try to set label1 to the first letter of string, using latest version of Swift. How to solve this issue? let preferences = UserDefaults.standard let name1 = "" + ...
0 votes
3 answers
6k views

I want to know how to get rest of string after specific character. I have checked link but have not found answer. Consider following code: let fullString = "Blue Sky" let spaceIndex = fullName....
5 votes
1 answer
5k views

Like the question says, if I have: XQQ230IJFEKJLDSAIOUOIDSAUIFOPDSFE28 How can I split this string at every 8th character to get: XQQ230IJ FEKJLDSA IOUOIDSA UIFOPDSA
p3scobar's user avatar
  • 131

15 30 50 per page
1
2 3