swift3.0常用操作包含刪除字符串(string),更換

1.刪除指定位置的字符串,

創(chuàng)新互聯(lián)建站網(wǎng)站建設(shè)公司,提供網(wǎng)站設(shè)計(jì)、做網(wǎng)站,網(wǎng)頁(yè)設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);可快速的進(jìn)行網(wǎng)站開(kāi)發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛(ài)的網(wǎng)站,是專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來(lái)合作!

let  str = "abcdefg"

let str3 = str.substring(from: str.index(str.endIndex, offsetBy: -4))

print(str3)輸出defg

let str4 = str.substring(to: str.index(str.startIndex, offsetBy: 4))

print(str4)輸出abcd

2、插入字符串

var  str = "abcdefg"

str.insert(contentsOf: "****".characters, at: str.index(str.startIndex, offsetBy: 3))

print(str)輸出abc****defg

3、更換字符串

var  str = "abcdefg"

let str2 = str.replacingOccurrences(of: "ab", with: "")

print(str2)輸出cdefg

網(wǎng)頁(yè)標(biāo)題:swift3.0常用操作包含刪除字符串(string),更換
本文路徑:http://bm7419.com/article10/jddjgo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號(hào)、網(wǎng)站營(yíng)銷、用戶體驗(yàn)、網(wǎng)站改版網(wǎng)站收錄、商城網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)