0

I want to calculate the total liabilities amount from webtable and need to compare with the total amount which is present on webpage.

I got the following error :

Illegal/unsupported escape sequence near index 1
\L
 ^

My code is :

{
totalLiabilities = driver.findElement(By.xpath(".//*[contains(text(),'Liabilities :')]")).getText();
        logger.info(totalLiabilities);
        Pattern patt = Pattern.compile("[-+^:$,a-zA-Z0-9]");
        Matcher matchh = patt.matcher(totalLiabilities);
        while(matchh.find())
        {
            String s2 = matchh.group();
            System.out.println(s2);
            totalLiabilities = totalLiabilities.replaceAll("\\"+s2, "");
        }
        totalLiabilities=totalLiabilities.replace("Liabilities", "");
        logger.info("total liabilities : "+totalLiabilities);
}
0

Try using replace instead of replaceAll. replace would also replace all the occurrences but won't use regular expression for that - just a char sequence. If you still need to replace the values by a regular expression you need to add \\ to your double-slash.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.