假设我将一个字符串定义为:
String splChrs = "/-@#$%^&_-+=()" ;
String inputString = getInputString(); //gets a String from end the user
Run Code Online (Sandbox Code Playgroud)
我想检查字符串“ inputString ”是否仅包含字符串“ splChrs ”中包含的特殊字符,即如果inputString仅包含“ splChrs ”中存在的字符,我想将布尔标志设置为true
eg: String inputString = "#######@"; //set boolean flag=true
Run Code Online (Sandbox Code Playgroud)
如果布尔标志包含“ splChrs ”中不包含的任何字母,则布尔标志设置为假
eg: String inputString = "######abc"; //set boolean flag=false
Run Code Online (Sandbox Code Playgroud)