Multiple delimiters in Scanner class of Java
问题 How do I use the useDelimiter() method of the Scanner class to use both the comma (,) and the new line character (\n) as delimiters? I am parsing some text from a csv file. 回答1: Scanner s = new Scanner("hello, world \n hello world"); s.useDelimiter(",|\\n"); while(s.hasNext()){ System.out.println(s.next()); } Output hello world hello world JavaDoc 回答2: How about useDelimiter(",|\\n"); 回答3: useDelimiter takes a regex pattern, so, it would be something like ",|\n" 回答4: Jigar is absolutely