Home > Mobile >  How can I use Scanner.useDlimiter to read a certain thing only
How can I use Scanner.useDlimiter to read a certain thing only

Time:06-22

i am trying to only read what is coming in run(...) inside of the clips but i am struggling to find how or any example to help. i am trying this code but it only reads what comes before and can't read anything if i only start with run(.

    public static void main (String[] args) {
         Scanner s = new Scanner(System.in).useDelimiter("run\\W");
//       System.out.println(s.next());     
         System.out.println(s.next());     
         // don't forget to close the scanner!!
         s.close(); 
    }
}

CodePudding user response:

Try this and see if it helps:

.useDelimiter("run\\(|\\)");
  • Related