fork download
  1. import java.util.*;
  2. import java.util.regex.*;
  3.  
  4. class Ideone
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. //String s = "something/something-else/pools[name='test'][scope='lan1']"; // => Matched!
  9. String s = "something/something-else/pools[name='test'][scope='lan1']/stats[base-string='10.10.10.10']";
  10. Pattern pattern = Pattern.compile(".+pools\\[name='[^']*']\\[scope='[^']*']$");
  11. Matcher matcher = pattern.matcher(s);
  12. if (matcher.find()){
  13. System.out.println("Matched!");
  14. } else {
  15. System.out.println("Not Matched!");
  16. }
  17. // => Not Matched!
  18. }
  19. }
Success #stdin #stdout 0.09s 47900KB
stdin
Standard input is empty
stdout
Not Matched!