Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

how can i find range of a string in another string swift

let str = "abcde"
if let range = str.range(of: "cd") {
  let substring = str[..<range.lowerBound] // or str[str.startIndex..<range.lowerBound]
  print(substring)  // Prints ab
}
else {
  print("String not present")
}
Comment

find range of string swift

let string = "Please Click Here"
if let range = string.range(of: "Click") {
   print(range)

}
Comment

PREVIOUS NEXT
Code Example
Swift :: make optional protocol swift 
Swift :: case insensitive multiple word search swift 
Swift :: Swift Switch Statement with Range 
Swift :: swiftui foreach enum not all cases 
Swift :: timer in swift stack overflow 
Swift :: swift set keyboard next functionality 
Swift :: swift string 
Swift :: swift extension Array with specific element type 
Swift :: uitextfield get focus swift 5 
Swift :: parse int in swift 
Swift :: swift enum xib 
Swift :: add arc swiftui 
Swift :: Swift How to declare an optional in Swift? 
Swift :: tap to delete xcode 
Swift :: Swift If-statement 
Swift :: swift multiple return values 
Swift :: swiftui rectangle top corners radius 
Swift :: uiviewcontroller title color 
Swift :: swift UI color rgb 
Swift :: fullscreencover swiftui 
Swift :: Swift Explicitly declaring an unwrapped optional 
Swift :: called a function after some time in swift 
Swift :: swift string pad 
Swift :: secure password field in textfield swift 
Swift :: Swift Logical Operators 
Swift :: how to add two right bar button item xcode 
Ruby :: hashwithindifferentaccess ruby 
Ruby :: array ruby taking 3 last value 
Ruby :: rails validators 
Ruby :: ruby integer to timestamp 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =