MSSQL에서 간단하게 문자 치환

 

'IT' 카테고리의 다른 글

[MSSQL] CASE WHEN 구문  (0) 2020.11.19
[inteliJ] lombok 설정 세팅 annotation  (0) 2020.11.19
[python] 여러개의 랜카드 ip 추출  (0) 2020.11.16
오픈소스 프로젝트들  (0) 2020.10.09
외부서비스 다운 확인  (0) 2020.10.08

Swift에서 replace는 어떻게 하나 하면서 찾아본...

역시나 있다...


그것도 아주 이쁘게..


You can use this:

let s = "This is my string"
let modified = s.replace(" ", withString:"+")    

If you add this extension method anywhere in your code:

extension String
{
    func replace(target: String, withString: String) -> String
    {
       return self.stringByReplacingOccurrencesOfString(target, withString: withString, options: NSStringCompareOptions.LiteralSearch, range: nil)
    }
}

Swift 3:

extension String
{
    func replace(target: String, withString: String) -> String
    {
        return self.replacingOccurrences(of: target, with: withString, options: NSString.CompareOptions.literal, range: nil)
    }
}


실제 링크는 여기

http://stackoverflow.com/questions/24200888/any-way-to-replace-characters-on-swift-string


Swift2


Swift3



+ Recent posts