Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8293347

Pattern with lookbehind ignores start parameter in Matcher.find(int start)

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      The lookbehind section of a pattern can match text that comes before the start parameter

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the code from "Source code for an executable test case"

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      false

      ---------- BEGIN SOURCE ----------
      import java.util.regex.Matcher;
      import java.util.regex.Pattern;

      public class Test {
          public static void main(String[] args) {
              Pattern pattern = Pattern.compile("(?<=te)st");
              Matcher matcher = pattern.matcher("test");
              System.out.println(matcher.find(2));
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


            rgiulietti Raffaello Giulietti
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: