2017-12-07 19 views

답변

1

가변 문자열은 특정 문자열 범위를 찾는 기능이 있습니다.

이 시도하고 (신속한 4)를 참조 :

let stringValue = "2/42" 
let attributedString: NSMutableAttributedString = NSMutableAttributedString(string: stringValue) 
let range: NSRange = attributedString.mutableString.range(of: "/42", options: .caseInsensitive) 
print("range - \(range)") 

결과 :
범위 - {1,3}

참조 스냅 :

enter image description here