grapheme_clusters是Ruby中的String類方法,用於返回給定字符串中的字素簇的數組。
用法: str.grapheme_clusters
參數:在這裏,str是給定的字符串。
返回值:字素簇的數組。
示例1:
# Ruby program to demonstrate
# the grapheme_clusters method
# Taking a string and
# using the method
puts "Sample".grapheme_clusters
puts "Program".grapheme_clusters
輸出:
S a m p l e P r o g r a m
示例2:
# Ruby program to demonstrate
# the grapheme_clusters method
# Taking a string and
# using the method
puts "Ruby\n".grapheme_clusters
puts "String".grapheme_clusters
輸出:
R u b y S t r i n g
相關用法
- Ruby String hex用法及代碼示例
- Scala String =~用法及代碼示例
- Scala String +用法及代碼示例
- Scala String ==用法及代碼示例
- Ruby String chr用法及代碼示例
- Ruby String eql?用法及代碼示例
- Scala String ===用法及代碼示例
- Ruby String reverse用法及代碼示例
- Ruby String length用法及代碼示例
- Ruby String casecmp用法及代碼示例
- Ruby String casecmp?用法及代碼示例
注:本文由純淨天空篩選整理自Kirti_Mangal大神的英文原創作品 Ruby | String grapheme_clusters Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。