Remove CSS link with Regex

1

Good morning, when pulling the html from the entire page in string it also brings some reference links:

<link href="~/Content/item/item.min.css" rel="stylesheet" />

I've already removed the tags and, but I need to remove this and I'm not getting it, the code I use to remove the script and style tags is this:

var regex = new Regex("(\<script(.+?)\</script\>)|(\<style(.+?)\</style\>)",
            RegexOptions.Singleline | RegexOptions.IgnoreCase);
        HTMLemString = regex.Replace(HTMLemString, "");

If someone can help me, I appreciate it.

    
asked by anonymous 15.03.2017 / 14:46

1 answer

0

As mentioned in the question comments, you can include the (<link[^>]*>) snippet in your regular expression. This expression gets all the link tags, as examples:

<link rel="stylesheet" type="text/css" href="cg.css">
<link href="~/Content/item/item.min.css" rel="stylesheet" />

You can view / test this regex here .

    
18.03.2017 / 00:22