fork(1) download
  1. import java.util.regex.Matcher;
  2. import java.util.regex.Pattern;
  3.  
  4. class Foo {
  5. public static void main(String[] args) {
  6. Matcher m = Pattern.compile(".*(?<=X)").matcher("Foo BarX Baz");
  7.  
  8. // limit matcher to first chars outside of normal lookahead scope
  9. m.region(0, 4);
  10.  
  11. // matcher should still find a match because of transparent bounds
  12. m.useTransparentBounds(true);
  13. System.out.println("found=" + m.find());
  14. System.out.println("result=" + m.group());
  15. }
  16. }
Runtime error #stdin #stdout 0.02s 245632KB
stdin
Standard input is empty
stdout
found=false