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();
}
}
}
|