首页 > 其他分享 >endsWith 判断字符串是否以某字符结尾的

endsWith 判断字符串是否以某字符结尾的

时间:2023-02-21 09:11:21浏览次数:23  
标签:结尾 endsWithExclamation endsWith 大小写 str 字符串

在上面的例子中,endsWith 方法被用来检查字符串 str 是否以感叹号结尾,
并将结果赋值给变量 endsWithExclamation。由于 str 确实以感叹号结尾,因此 endsWithExclamation 的值为 true。

需要注意的是,endsWith 方法是区分大小写的。如果需要忽略大小写,可以将字符串全部转换成小写或大写,再进行比较。

标签:结尾,endsWithExclamation,endsWith,大小写,str,字符串
From: https://www.cnblogs.com/pansidong/p/17139701.html

相关文章