搜索
首页 电脑/网络 软件 系统软件

正则表达式有什么应用?

正则表达式有什么应用?

全部回答

2017-07-28

47 0

    import java。io。*;import java。util。regex。*;public class Printer { public static void main(String[] args) { System。
  out。println("\nPlease enter the input string:\n"); BufferedReader reader = new BufferedReader(new InputStreamReader(System。
    in)); String inputString; boolean isOK = false; try { while(!isOK) { if((inputString = reader。
  readLine()) != null) { if(inputString。  length() > 200) { System。out。println("The string exceeds 200 characters。
  \nPlease enter again!\n"); } else { Pattern regex = Pattern。  compile("[^@#$%&*/^]+"); Matcher matcher = regex。
  matcher(inputString); boolean isMatched = matcher。matches(); if(!isMatched) { System。  out。
  println("The String can't contain @,#,$,%,*,& and ^。\nPlease enter again!\n"); } else { isOK = true; System。
  out。println("\nYour input string is: \n" + inputString); } } } } } catch(IOException e) { e。  printStackTrace(); } }}。
  

类似问题换一批

热点推荐

热度TOP

相关推荐
加载中...

热点搜索 换一换

电脑/网络
系统软件
程序设计
电脑装机
操作系统/系统故障
硬件
笔记本电脑
百度
互联网
反病毒
软件
软件
系统软件
多媒体软件
办公软件
网络软件
图像处理软件
系统软件
系统软件
举报
举报原因(必选):
取消确定举报