当前位置:网站首页>输入字符串,替换其中敏感词进行输出
输入字符串,替换其中敏感词进行输出
2022-08-11 05:12:00 【余谦吖】
例:字符串“打劫!我有枪”,“枪”是敏感词汇,替换为“*”,并输出打印
package Day0712;
import java.util.Scanner;
public class one {
public static void main(String[] args) {
//输入
Scanner sc = new Scanner(System.in);
//设置敏感词汇
String mg = "枪";
//设置输入类型为string
String say = sc.next();
//匹配字符串中是否含有敏感词汇
if (say.contains(mg)){
//设置敏感词汇替换
String temp = "*";
//敏感词汇替换后输出
say = say.replace(mg,temp);
}
System.out.println(say);
}
}
边栏推荐
- Switches and routers technology - 21 - RIP routing protocol
- 关于ie下href有中文出现RFC 7230 and RFC 3986问题的研究
- ARM结构体系4:嵌入式硬件平台接口开发
- Oracle常用语句归纳_持续更新
- Internet Protocol 1
- Golden Warehouse Database KingbaseGIS User Manual (6.10. Geometric Object Operation Operator)
- 4 Module 3: Literature Reading and Research Methods
- 2022 building welder (building a special type of work) examination questions and simulation test
- MySQL存储引擎概念
- Decryption of BitLocker
猜你喜欢
Switch and Router Technology - 28 - NSSA Areas for OSPF
Configure checkstyle in IDEA
leetcode 9. Palindromic Numbers
Redis-数据类型(基本指令、String、List、Set、Hash、ZSet、BitMaps、HyperLogLog、GeoSpatial)/发布和订阅
Linux中安装redis
Delphi7学习记录-demo实例
Delphi7 learning record - demo example
实战noVNC全过程操作(包含遇到的问题和解决)
【嵌入式开源库】MultiButton的使用,简单易用的事件驱动型按键驱动模块
Optimization is a kind of habit low starting point is the "standing near the critical"
随机推荐
3 Module 2: Use of scientific research tools
oracle tablespace and user creation
Weekly recommended short video: your commonly used Polaroid, its predecessor turned out to be like this!
项目实战第二十七讲:状态模式在重名品牌中的应用
面试题整理
2.2 user manual] [QNX Hypervisor 10.15 vdev timer8254
【无2022上海市安全员A证考试题库及模拟考试
【嵌入式开源库】cJSON的使用,高效精简的json解析库
每周推荐短视频:你常用的拍立淘,它的前身原来是这样的!
Four functional interfaces
How to use svg-icon (svg-sprite-loader plugin)
Switch and Router Technology - 36-Port Mirroring
The use of async (asynchronous) and await
guava RateLimiter uniform current limit
[QNX Hypervisor 2.2用户手册]10.15 vdev timer8254
Idea 2021.3.3版本文件目录展开
2021 Network Planning Designer Afternoon Case Questions
JedisLock_Redis分布式锁实现_转载
2022 Quality Officer-Civil Construction Direction-General Basic (Quality Officer) Exam Mock 100 Questions and Online Mock Exam
Internet Protocol 1