• Source
    1. import java.util.*;
    2. import java.lang.*;
    3. import java.io.*;
    4. import java.util.regex.Matcher;
    5. import java.util.regex.Pattern;
    6.  
    7. /* Name of the class has to be "Main" only if the class is public. */
    8. class Ideone
    9. {
    10. public static void main (String[] args) throws java.lang.Exception
    11. {
    12. Pattern pattern = Pattern.compile("^\\w{2,}\\s");
    13. Matcher matcher = pattern.matcher("Boston test");
    14.  
    15. if (matcher.find()) System.out.println(matcher.group(0));
    16.  
    17. }
    18. }