「Swift」hasSuffixでサフィックスをチェックするサンプル

書式
文字列.hasSuffix(xxx)
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
let cft = "https://arkgame.com"
print(cft.hasSuffix("m"))
print(cft.hasSuffix("com"))
print(cft.hasSuffix("net"))
// 大文字
print(cft.uppercased().hasSuffix("Com".uppercased()))
let cft = "https://arkgame.com" print(cft.hasSuffix("m")) print(cft.hasSuffix("com")) print(cft.hasSuffix("net")) // 大文字 print(cft.uppercased().hasSuffix("Com".uppercased()))
let cft = "https://arkgame.com"
 
print(cft.hasSuffix("m")) 
print(cft.hasSuffix("com")) 
print(cft.hasSuffix("net")) 
// 大文字
print(cft.uppercased().hasSuffix("Com".uppercased()))

実行結果
true
true
false
true

Swift

Posted by arkgame