fork download
  1. import java.util.regex.Pattern;
  2. import java.util.regex.Matcher;
  3.  
  4. class Ideone {
  5. private static final String PATTERN_TEMPLATE = "^.*@==(.*?)(?:\\?.*)?$";
  6.  
  7. public static void main (String[] args) {
  8. final Pattern pattern = Pattern.compile(PATTERN_TEMPLATE);
  9.  
  10. final String firstTest =
  11. "https://e...content-available-to-author-only...e.com/helloworld/.@==imhere";
  12. final Matcher firstMatcher = pattern.matcher(firstTest);
  13. if (firstMatcher.matches()) {
  14. System.out.println(firstMatcher.group(1));
  15. }
  16.  
  17. final String secondTest =
  18. "https://e...content-available-to-author-only...e.com/helloworld/.@==imnothere?param1=value1";
  19. final Matcher secondMatcher = pattern.matcher(secondTest);
  20. if (secondMatcher.matches()) {
  21. System.out.println(secondMatcher.group(1));
  22. }
  23. }
  24. }
Success #stdin #stdout 0.08s 33808KB
stdin
Standard input is empty
stdout
imhere
imnothere