当前位置:网站首页>输入字符串,替换其中敏感词进行输出
输入字符串,替换其中敏感词进行输出
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);
}
}
边栏推荐
- MySQL索引
- guava RateLimiter uniform current limit
- How IP-Guard prohibits running U disk programs
- Delphi7学习记录-demo实例
- Sub-database sub-table ShardingSphere-JDBC notes arrangement
- 2022 coal mine gas inspection test, simulation test question and answer
- C statement: data storage
- [FPGA tutorial case 49] Control case 1 - FPGA-based PID controller verilog implementation
- Day38 LeetCode
- Redis详解
猜你喜欢
关于ie下href有中文出现RFC 7230 and RFC 3986问题的研究
ARM结构体系4:嵌入式硬件平台接口开发
How IP-Guard prohibits running U disk programs
leetcode 9. Palindromic Numbers
实战noVNC全过程操作(包含遇到的问题和解决)
IDEA模板总结
Core Data 多线程设计
IDEA中配置checkstyle
[E-commerce operation] How to formulate a social media marketing strategy?
【嵌入式开源库】MultiButton的使用,简单易用的事件驱动型按键驱动模块
随机推荐
@Resource和@Autowired的区别
Network Skill Tree
Unity WebGL RuntimeError: integer overflow
Redis-使用jedis连接linux中redis服务器失败的解决方案
2022 building welder (building a special type of work) examination questions and simulation test
IDEA使用记录
Four functional interfaces
群晖DS220+ 应用小笔记
In the closing pages/uninstall (unload) sends a request to the server before the document
FPGA engineer interview questions collection 111~120
BGP Comprehensive Experiment
Switch and Router Technology-27-OSPF Route Redistribution
guava RateLimiter uniform current limit
Idea essential skills to improve work efficiency
JedisLock_Redis分布式锁实现_转载
Mysql入门练习
【嵌入式开源库】MultiButton的使用,简单易用的事件驱动型按键驱动模块
02.折叠隐藏文字
Day38 LeetCode
3 Module 2: Use of scientific research tools