0

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(); 
    }
}
theworld
  • 3
  • 1
  • "Dont forget to close the scanner"? Nono. You do __not__ want to close the scanner. You don't close stuff you did not make (and you did not make `System.in`. Please edit the question with an example input (as in, what you type in the command line), and what you'd like `s.next()` to return when that is typed. – rzwitserloot Jun 21 '22 at 15:40
  • As i said in the question, i only wanna read what comes in the clips when i type run() so for example, as an input run(hello world) and as a return "hello world" – theworld Jun 21 '22 at 15:45
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jun 21 '22 at 16:14

1 Answers1

0

Try this and see if it helps:

.useDelimiter("run\\(|\\)");
Lastun
  • 16
  • 3