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.
Code:
String mobilenumber="00955555555555";
//Date validate = null;
{
List<WebElement> 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);