I’m in doubt on how to do an regex, to break an string in all white-spaces, hyphen and semicolon, it’s in Java. I’m doing:String[] tmp = input.nextLine().split("\\s:-");
but it’s not working, which is the right way ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’re currently splitting on all three of them in a row. Try character classes, which picks out any one from the selection:
String[] tmp = input.nextLine().split("[\\s:\\-]");(hyphens have meaning in character classes, so you should escape them, too.)