I want to remove 'color' attribute alone in style attributes of HTML and at same time, not to remove color in HTML view content.
Here, I provided the sample HTML.
Step 1: Defining regex for html codes range.
<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>
If I use the above regex pattern expression to select HTML language codes then it selects the content within "<" and ">". Please refer the picture.selects only html code and not the HTML view content
<?xml version="1.0" ?>
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="TX20_HTM 20.0.405.501" name="GENERATOR" />
<title> well marked style="color:blue;"</title>
</head>
<body style="color:red;"> this is atest
</body>
</html>
Step 2: Defining regex to remove color attributes from HTML coding.
But, within the html attribute contents I want to remove color alone. I have a regex expression to remove the color attributes.
(?i)((background-color|color)\:([a-zA-Z0-9#)])[a-zA-Z0-9.(),]+;*)
But, the above regex pattern also remove the color from HTML View content as well. Please refer the picture.
Actually, for my case, the color attributes should not be removed from the HTML View content.
Step 3: I want to mix the Step 1 and Step 2 regex
Basically, What I'm trying to mix up these two expressions but, it is not resulting the correct what I expect and I'm not familiar about these expressions..
Please suggest..
which the regex pattern can be used to achieve the above said requirement?