fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.*;
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. String str = "/hello.there#test";
  10. Pattern ptrn = Pattern.compile("/([^#?]*)");
  11. Matcher matcher = ptrn.matcher(str);
  12. if (matcher.find()) {
  13. System.out.println(matcher.group()); // /hello.there
  14. System.out.println(matcher.group(1)); // hello.there
  15. }
  16. }
  17. }
Success #stdin #stdout 0.03s 711168KB
stdin
Standard input is empty
stdout
/hello.there
hello.there