Separate line number one



  • Line in format

    24 Example 62.34 7
    

    We need to get the first one out of this.

    24
    

    And you need to get everything that's after the first.

     Example 62.34 7
    


  • That's the decision in regular terms.

    String s = "24 Example 62.34 7 ";
    Pattern p = Pattern.compile("(^|\\s+)([0-9]+)(.*)");
    Matcher m = p.matcher(s);
    if (m.find()) {
        System.out.println(m.group(2));
        System.out.println(m.group(3));
    }
    

    Output

    24
     Example 62.34 7 
    

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2