Home > Back-end >  How do I use a delimiter with Scanner.useDelimiter in Java to delimeter [,?
How do I use a delimiter with Scanner.useDelimiter in Java to delimeter [,?

Time:12-21

want to use delimer for [, in the same delimter.

if the text for example is: [7,(-1-5i)]

so to make a delimiter for [, so I can separate the 7 as a intger

CodePudding user response:

You need to escape the [ character, which is has a special meaning in a regex:

myScanner.useDelimiter("[\\[,]");
  • Related