当前位置:网站首页>输入字符串,替换其中敏感词进行输出
输入字符串,替换其中敏感词进行输出
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);
}
}
边栏推荐
- Let's talk programming languages together
- 批量修改数据库等视频文件名称
- ARM结构体系4:嵌入式硬件平台接口开发
- Smart Pointer Notes
- 2021 Network Planning Designer Afternoon Case Questions
- 【无标题】2022年胺基化工艺考试题模拟考试题库及在线模拟考试
- ARM Architecture 4: Embedded Hardware Platform Interface Development
- 02. Fold hidden text
- Some common mysql entry exercises
- Zabbix builds enterprise-level monitoring and alarm platform
猜你喜欢

元宇宙社交应用,靠什么吸引用户「为爱发电」?

Paper Notes: BBN: Bilateral-Branch Network with Cumulative Learning for Long-Tailed Visual Recognition

Switch and Router Technology - 25 - OSPF Multi-Area Configuration

nodes服务器

分库分表之sharding-proxy

【ARM】rk3399挂载nfs报错

IDEA中配置checkstyle

Trilium使用总结

ESP8266 教程3 — 通过TCP组建局域网并通信

HAVE FUN | "SOFA Planet" spacecraft plan, the latest progress of source code analysis activities
随机推荐
Kong实现禁止国外IP访问
阿里云无法远程连接数据库MySQL错误码10060解决办法_转载
3 模块二:科研工具使用
玩转mysql之查看mysql版本号
K8s Review Notes 7--K8S Implementation of Redis Standalone and Redis-cluster
【无2022上海市安全员A证考试题库及模拟考试
分库分表之sharding-proxy
2.2 user manual] [QNX Hypervisor 10.15 vdev timer8254
Internet Protocol 1
Switch and Router Technology-27-OSPF Route Redistribution
2022建筑焊工(建筑特殊工种)考题及模拟考试
[Untitled] 2022 Amination Process Exam Questions Mock Exam Question Bank and Online Mock Exam
Switch and Router Technology - 32 - Named ACL
Delphi7学习记录-demo实例
Switch and Router Technology-35-NAT to PAT
宝塔Linux环境下redis开启多端口
【无标题】2022年胺基化工艺考试题模拟考试题库及在线模拟考试
Kong implements ban on foreign IP access
Mysql introductory exercise
[ARM] rk3399 mounts nfs error