Error[8]: Undefined offset: 4, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我想创建一个过程来找出字符串中有多少个单词,用空格,逗号或其他字符分隔.然后将总数加起来. 我正在制作一个平均计算器,所以我想要数据的总数,然后将所有单词加起来. 更新: Xcode 8.2.1• Swift 3.0.2 let sentence = "I want to an algorithm that could help find out how many words are there 我想创建一个过程来找出字符串中有多少个单词,用空格,逗号或其他字符分隔.然后将总数加起来.

我正在制作一个平均计算器,所以我想要数据的总数,然后将所有单词加起来.

解决方法 更新: Xcode 8.2.1• Swift 3.0.2

let sentence = "I want to an algorithm that Could help find out how many words are there in a string separated by space or comma or some character. And then append each word separated by a character to an array which Could be added up later I'm making an average calculator so I want the total count of data and then add up all the words. By words I mean the numbers separated by a character,preferably space Thanks in advance"let wordList =  sentence.components(separatedBy: .punctuationCharacters).joined().components(separatedBy: " ").filter{!
extension String {    var words: [String] {        var words: [String] = []        enumerateSubstrings(in: startIndex..<endindex,options: .byWords) { word,_,_ in            guard let word = word else { return }            words.append(word)        }        return words    }}print(sentence.words) // ["I","want","to","an","algorithm","that","Could","help","find","out","how","many","words","are","there","in","a","string","separated","by","space","or","comma","some","character","And","then","append","each","word","array","which","be","added","up","later","I'm","making","average","calculator","so","I","the","total","count","of","data","and","add","all","By","mean","numbers","preferably","Thanks","advance"]
.isEmpty}print(wordList) // [I,want,to,an,algorithm,that,Could,help,find,out,how,many,words,are,there,in,a,string,separated,by,space,or,comma,some,character,And,then,append,each,word,array,which,be,added,up,later,Im,making,average,calculator,so,I,the,total,count,of,data,and,add,all,By,mean,numbers,preferably,Thanks,advance]"print(wordList.count) // 79
let sentence = "I want to an algorithm that Could help find out how many words are there in a string separated by space or comma or some character. And then append each word separated by a character to an array which Could be added up later I'm making an average calculator so I want the total count of data and then add up all the words. By words I mean the numbers separated by a character,preferably space Thanks in advance"let wordList =  sentence.componentsSeparatedByCharactersInSet(NSCharacterSet.punctuationCharacterSet()).joinWithSeparator("").componentsSeparatedByString(" ").filter{
extension String {    var words: [String] {        var result:[String] = []        enumerateSubstringsInRange(characters.indices,options: .ByWords) { result.append([+++].substring!) }        return result    }}
!= ""}print(wordList) // [I,advance]"print(wordList.count) // 79

Swift 2.x

[+++]

问题是得到单词的计数,但是如果你需要这些单词,你可以使用这个扩展改编自Martin R在这个answer中建议的方法也能够处理撇号:

[+++] 总结

以上是内存溢出为你收集整理的用于字数计算的Swift字符串中的字数全部内容,希望文章能够帮你解决用于字数计算的Swift字符串中的字数所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 5, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我想创建一个过程来找出字符串中有多少个单词,用空格,逗号或其他字符分隔.然后将总数加起来. 我正在制作一个平均计算器,所以我想要数据的总数,然后将所有单词加起来. 更新: Xcode 8.2.1• Swift 3.0.2 let sentence = "I want to an algorithm that could help find out how many words are there 我想创建一个过程来找出字符串中有多少个单词,用空格,逗号或其他字符分隔.然后将总数加起来.

我正在制作一个平均计算器,所以我想要数据的总数,然后将所有单词加起来.

解决方法 更新: Xcode 8.2.1• Swift 3.0.2

let sentence = "I want to an algorithm that Could help find out how many words are there in a string separated by space or comma or some character. And then append each word separated by a character to an array which Could be added up later I'm making an average calculator so I want the total count of data and then add up all the words. By words I mean the numbers separated by a character,preferably space Thanks in advance"let wordList =  sentence.components(separatedBy: .punctuationCharacters).joined().components(separatedBy: " ").filter{!
extension String {    var words: [String] {        var words: [String] = []        enumerateSubstrings(in: startIndex..<endindex,options: .byWords) { word,_,_ in            guard let word = word else { return }            words.append(word)        }        return words    }}print(sentence.words) // ["I","want","to","an","algorithm","that","Could","help","find","out","how","many","words","are","there","in","a","string","separated","by","space","or","comma","some","character","And","then","append","each","word","array","which","be","added","up","later","I'm","making","average","calculator","so","I","the","total","count","of","data","and","add","all","By","mean","numbers","preferably","Thanks","advance"]
.isEmpty}print(wordList) // [I,want,to,an,algorithm,that,Could,help,find,out,how,many,words,are,there,in,a,string,separated,by,space,or,comma,some,character,And,then,append,each,word,array,which,be,added,up,later,Im,making,average,calculator,so,I,the,total,count,of,data,and,add,all,By,mean,numbers,preferably,Thanks,advance]"print(wordList.count) // 79
let sentence = "I want to an algorithm that Could help find out how many words are there in a string separated by space or comma or some character. And then append each word separated by a character to an array which Could be added up later I'm making an average calculator so I want the total count of data and then add up all the words. By words I mean the numbers separated by a character,preferably space Thanks in advance"let wordList =  sentence.componentsSeparatedByCharactersInSet(NSCharacterSet.punctuationCharacterSet()).joinWithSeparator("").componentsSeparatedByString(" ").filter{
extension String {    var words: [String] {        var result:[String] = []        enumerateSubstringsInRange(characters.indices,options: .ByWords) { result.append(.substring!) }        return result    }}
!= ""}print(wordList) // [I,advance]"print(wordList.count) // 79

Swift 2.x

[+++]

问题是得到单词的计数,但是如果你需要这些单词,你可以使用这个扩展改编自Martin R在这个answer中建议的方法也能够处理撇号:

[+++] 总结

以上是内存溢出为你收集整理的用于字数计算的Swift字符串中的字数全部内容,希望文章能够帮你解决用于字数计算的Swift字符串中的字数所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 6, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我想创建一个过程来找出字符串中有多少个单词,用空格,逗号或其他字符分隔.然后将总数加起来. 我正在制作一个平均计算器,所以我想要数据的总数,然后将所有单词加起来. 更新: Xcode 8.2.1• Swift 3.0.2 let sentence = "I want to an algorithm that could help find out how many words are there 我想创建一个过程来找出字符串中有多少个单词,用空格,逗号或其他字符分隔.然后将总数加起来.

我正在制作一个平均计算器,所以我想要数据的总数,然后将所有单词加起来.

解决方法 更新: Xcode 8.2.1• Swift 3.0.2

let sentence = "I want to an algorithm that Could help find out how many words are there in a string separated by space or comma or some character. And then append each word separated by a character to an array which Could be added up later I'm making an average calculator so I want the total count of data and then add up all the words. By words I mean the numbers separated by a character,preferably space Thanks in advance"let wordList =  sentence.components(separatedBy: .punctuationCharacters).joined().components(separatedBy: " ").filter{!
extension String {    var words: [String] {        var words: [String] = []        enumerateSubstrings(in: startIndex..<endindex,options: .byWords) { word,_,_ in            guard let word = word else { return }            words.append(word)        }        return words    }}print(sentence.words) // ["I","want","to","an","algorithm","that","Could","help","find","out","how","many","words","are","there","in","a","string","separated","by","space","or","comma","some","character","And","then","append","each","word","array","which","be","added","up","later","I'm","making","average","calculator","so","I","the","total","count","of","data","and","add","all","By","mean","numbers","preferably","Thanks","advance"]
.isEmpty}print(wordList) // [I,want,to,an,algorithm,that,Could,help,find,out,how,many,words,are,there,in,a,string,separated,by,space,or,comma,some,character,And,then,append,each,word,array,which,be,added,up,later,Im,making,average,calculator,so,I,the,total,count,of,data,and,add,all,By,mean,numbers,preferably,Thanks,advance]"print(wordList.count) // 79
let sentence = "I want to an algorithm that Could help find out how many words are there in a string separated by space or comma or some character. And then append each word separated by a character to an array which Could be added up later I'm making an average calculator so I want the total count of data and then add up all the words. By words I mean the numbers separated by a character,preferably space Thanks in advance"let wordList =  sentence.componentsSeparatedByCharactersInSet(NSCharacterSet.punctuationCharacterSet()).joinWithSeparator("").componentsSeparatedByString(" ").filter{
extension String {    var words: [String] {        var result:[String] = []        enumerateSubstringsInRange(characters.indices,options: .ByWords) { result.append(.substring!) }        return result    }}
!= ""}print(wordList) // [I,advance]"print(wordList.count) // 79

Swift 2.x

问题是得到单词的计数,但是如果你需要这些单词,你可以使用这个扩展改编自Martin R在这个answer中建议的方法也能够处理撇号:

[+++] 总结

以上是内存溢出为你收集整理的用于字数计算的Swift字符串中的字数全部内容,希望文章能够帮你解决用于字数计算的Swift字符串中的字数所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
用于字数计算的Swift字符串中的字数_app_内存溢出

用于字数计算的Swift字符串中的字数

用于字数计算的Swift字符串中的字数,第1张

概述我想创建一个过程来找出字符串中有多少个单词,用空格,逗号或其他字符分隔.然后将总数加起来. 我正在制作一个平均计算器,所以我想要数据的总数,然后将所有单词加起来. 更新: Xcode 8.2.1• Swift 3.0.2 let sentence = "I want to an algorithm that could help find out how many words are there 我想创建一个过程来找出字符串中有多少个单词,用空格,逗号或其他字符分隔.然后将总数加起来.

我正在制作一个平均计算器,所以我想要数据的总数,然后将所有单词加起来.

解决方法 更新: Xcode 8.2.1• Swift 3.0.2

let sentence = "I want to an algorithm that Could help find out how many words are there in a string separated by space or comma or some character. And then append each word separated by a character to an array which Could be added up later I'm making an average calculator so I want the total count of data and then add up all the words. By words I mean the numbers separated by a character,preferably space Thanks in advance"let wordList =  sentence.components(separatedBy: .punctuationCharacters).joined().components(separatedBy: " ").filter{!
extension String {    var words: [String] {        var words: [String] = []        enumerateSubstrings(in: startIndex..<endindex,options: .byWords) { word,_,_ in            guard let word = word else { return }            words.append(word)        }        return words    }}print(sentence.words) // ["I","want","to","an","algorithm","that","Could","help","find","out","how","many","words","are","there","in","a","string","separated","by","space","or","comma","some","character","And","then","append","each","word","array","which","be","added","up","later","I'm","making","average","calculator","so","I","the","total","count","of","data","and","add","all","By","mean","numbers","preferably","Thanks","advance"]
.isEmpty}print(wordList) // [I,want,to,an,algorithm,that,Could,help,find,out,how,many,words,are,there,in,a,string,separated,by,space,or,comma,some,character,And,then,append,each,word,array,which,be,added,up,later,Im,making,average,calculator,so,I,the,total,count,of,data,and,add,all,By,mean,numbers,preferably,Thanks,advance]"print(wordList.count) // 79
let sentence = "I want to an algorithm that Could help find out how many words are there in a string separated by space or comma or some character. And then append each word separated by a character to an array which Could be added up later I'm making an average calculator so I want the total count of data and then add up all the words. By words I mean the numbers separated by a character,preferably space Thanks in advance"let wordList =  sentence.componentsSeparatedByCharactersInSet(NSCharacterSet.punctuationCharacterSet()).joinWithSeparator("").componentsSeparatedByString(" ").filter{
extension String {    var words: [String] {        var result:[String] = []        enumerateSubstringsInRange(characters.indices,options: .ByWords) { result.append(.substring!) }        return result    }}
!= ""}print(wordList) // [I,advance]"print(wordList.count) // 79

Swift 2.x

问题是得到单词的计数,但是如果你需要这些单词,你可以使用这个扩展改编自Martin R在这个answer中建议的方法也能够处理撇号:

总结

以上是内存溢出为你收集整理的用于字数计算的Swift字符串中的字数全部内容,希望文章能够帮你解决用于字数计算的Swift字符串中的字数所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1013964.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存