I found a Regex which retrieves the Parent domain from a URL. When I tried using the same Regex Expression in Apex using Pattern and Matcher, it's giving me an error of:
Illegal string literal: Invalid string literal '(\w+.\w+)$'. Illegal character sequence \w' in string literal.
Below is my code:
Account aa = [SELECT id, Website from Account WHERE Id = '0016F00002QeRqw'];
String d = aa.Website;
String regexx = '(\w+\.\w+)$';
Pattern mPat = Pattern.compile(regexx);
Matcher myMatch = mPat.matcher(d);
system.debug('--'+myMatch);
I am not that good in the Regex and could use some help finding the issue.