I have a below string in Java
String text = "<link href=\"https://example.com\" rel=\"stylesheet\" type=\"text/css\" /> <link href=\"https://example.com\" rel=\"stylesheet\" type=\"text/css\" /> <div class=\"fr-view\"> <div></div><p>analyst</p> </div>";
Expected Output:
text = <link href='https://example.com' rel='stylesheet' type='text/css' /> <link href='https://example.com' rel='stylesheet' type='text/css' /> <div class='fr-view'> <div></div><p>analyst</p> </div>
Basically I want to replace the html attributed in double quotes with single quotes. I have used below regex which works perfectly but I get the sonar issue.
text.replaceAll("\\p{Cntrl}|\"|\\\\", "'");
Sonar issue I am facing with above regex is "Single-character alternations in regular expressions should be replaced with character classes".
Can anyone suggest the alternate regex to achieve the same.
Thanks