title: Regular Exp: Matcher: how to get last occurence in the group
body: <p>I have table structure where I need to capture the Auth code. I have used  the regex and matcher method find(). However, there will be multiple codes generated and I need to get the recent one. I tried below code which captures only 1st occurrence. Please let me know How I can capture last occurrence of the code.</p>
  
  <p>Code:</p>
  
  <pre><code>String mobilenumber="00955555555555"; 
  
  //Date validate = null;
  
      {
      List&lt;WebElement&gt; rows = driver1.findElements(By.cssSelector("tr"));
      for (WebElement row : rows)
      {
          String text = row.getText();
          if (text.contains(mobilenumber))
          {
              String regex = ": (\\d+)"; //Your authentication code is
              Pattern pattern = Pattern.compile(regex);
              Matcher matcher = pattern.matcher(text);
  
              if (matcher.find())             
                   {
  
                  valueis = matcher.group(1);
                  System.out.println(valueis);
  </code></pre>