kotlin中判断字符串

Given a string and a character, we have to remove all occurrences of the character in given string.

给定一个字符串和一个字符,我们必须删除给定字符串中所有出现的字符。

Example:

例:

    Input:
string = "includeHelp Delhi"
Output:
String after removing character : "includeelp Deli"

在Kotlin中删除字符串中所有出现的字符的程序 (Program to remove all occurrences of a character in a string in Kotlin)

package com.includehelp.basic
import java.util.*
//Main Function, entry Point of Program
fun main(args: Array<String>) {
// InputStream to get Input
val scanner = Scanner(System.`in`)
//Input String
print("Enter String : ")
var str = scanner.nextLine()
//Input Character to Remove from String
print("Enter Character : ")
val c = scanner.next()[0]
//Replace character with Empty String
val newStr=str.replace(c.toString(),"",ignoreCase = true)
//Print String after Replacement
println("String after removing character : $newStr ")
}

Output

输出量

Run 1:
Enter String : includeHelp Delhi
Enter Character : h
String after removing character : includeelp Deli
---
Run 2:
Enter String : corona virus global death rate
Enter Character : o
String after removing character : crna virus glbal death rate

翻译自: https://www.includehelp.com/kotlin/remove-all-occurrences-of-a-character-in-a-string.aspx

kotlin中判断字符串

kotlin中判断字符串_Kotlin程序删除字符串中所有出现的字符相关推荐

  1. C语言中删除字符串中一个字母,C程序删除字符串中除字母之外的所有字符

    C程序删除字符串中除字母之外的所有字符 在此示例中,您将学习从用户输入的字符串中删除除字母之外的所有字符. 要理解此示例,您应该了解以下C语言编程主题: 删除字符串中除字母之外的字符#include ...

  2. kotlin中判断字符串_Kotlin程序查找字符串中字符的频率

    kotlin中判断字符串 Given a string and a character, we have to find the frequency of the character in the s ...

  3. kotlin 字符串_Kotlin程序确定字符串是否具有所有唯一字符

    kotlin 字符串 Given a string, we have to check whether it has all unique characters or not. 给定一个字符串,我们必 ...

  4. 删除数组中某个指定元素或删除数组中某个对象元素

    ES6--删除数组中某个指定元素或删除数组中某个对象 1.删除数组中某个指定元素 2.删除数组中的某个对象 1.删除数组中某个指定元素 let index = this.array.indexOf(n ...

  5. kotlin 字符串去空格_Kotlin程序从字符串中删除所有空格

    kotlin 字符串去空格 Given a string, we have to remove all whitespaces from it. 给定一个字符串,我们必须从中删除所有空格. Examp ...

  6. (小甲鱼python)字符串系列笔记合集四 第四课、字符串IV总结 删除字符串中(左右)空格 删除指定的前缀或者后缀 字符串以参数指定的分隔符为依据进行切割,将切割后的结果返回一个三元组

    一.字符串总结四 1.删除字符串中(左右)空格或者与之匹配的字符串 "字符串".lstrip(char=None) 删除左空格 "字符串".rstrip(cha ...

  7. [转载] kotlin 字符串_Kotlin基本类型字符串

    参考链接: Python字符串串联Concatenation kotlin 字符串 Kotlin has five basic data types. In a previous post, we d ...

  8. scala反转字符串_Scala程序反转字符串

    scala反转字符串 反转字符串 (Reversing a string) Logically, reversing is swapping the values from index 1 with ...

  9. 题目1168:字符串的查找删除(字符串操作)

    题目链接:http://ac.jobdu.com/problem.php?pid=1168 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus 参考代码: ...

最新文章

  1. MongoDB入门及 c# .netcore客户端MongoDB.Driver2.9.1使用
  2. 手动选择显示_QGIS 二次开发笔记(2)——显示图层
  3. pla3d打印材料密度_3D打印金属材料模型过程中常见问题
  4. P2241 统计方形(数据加强版)-- 70分 python3实现
  5. 炸裂!微信支付的架构太牛了!(微信跨平台开发框架)
  6. 手机写python爬虫_零基础开始写Python爬虫心得
  7. nginx+php配置
  8. uefi 懒人版黑苹果_macOS Sierra 10.12.6(16G29) 变色龙引导懒人版CDR黑苹果镜像
  9. 节点name在graph中无法展示_小节点 · 大奥秘│这正是你想学习的精妙休闲观景空间!(内含视频讲解)...
  10. eclipse安装及配置android基础教程
  11. 有没免费云桌面,免费桌面虚拟化软件? 确实有的
  12. Gym - 102394I Interesting Permutation(思维)
  13. asp.net 中 使用ajax 和浏览器的关系
  14. 如何让你画里的鱼,游进海里?
  15. DMS应用性能管理案例分析(二)
  16. python 路径格式化_吐血整理!140种Python标准库、第三方库和外部工具都有了!...
  17. 为什么越来越多的企业选择智能客服系统?
  18. html查看更多隐藏内容,jQuery点击显示隐藏更多文字内容插件jquery.morecontent.js
  19. 新闻类客户端代码阅读笔记
  20. 爬取智联招聘上24座热门城市中Java招聘信息

热门文章

  1. linux php不能写文件内容,php 在linux系统下写出文件问题
  2. make命令及makefile
  3. 计算机常用主题词,标引主题词的目的是( )。A.反映文件的全部内容B.便于计算机检索和管理C.供归_考题宝...
  4. java web使用jquery,JAVA_Web_JQuery
  5. python嵌套列表操作_python基础(list列表的操作,公共方法,列表嵌套,元祖)...
  6. aop注解配置切点 spring_springboot aop 自定义注解方式实现一套完善的日志记录
  7. JAVA知识基础(五):深入理解final关键字
  8. virtualbox的USB识别
  9. telnet 功能启用并测试端口是否正常
  10. 网页中查看pdf文档