Question: Sorry my title must be quite confused. What I want to mean is like this. Let's say, I have total more than 100 html existing files. I want to put this code before end of the head tag. 

```
        <script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

```

I don't want to open every page and insert manually. Because it's lots of file. I tried to do with Find & replace, but it doesn't allow me to add because it's have lots of lines.

So anyway to inject the codes to every page very easily ? 

Please kindly help thanks.

Answer: 
Exception handling is heavy and should be used as a last resort and only for actual exceptions. Try this. It checks for a valid html hex color and then tries named colors. 

```
protected static bool CheckValidFormatHtmlColor(string inputColor)
{
       //regex from http://stackoverflow.com/a/1636354/2343
       if (Regex.Match(inputColor, "^#(?:[0-9a-fA-F]{3}){1,2}$").Success)
           return true;

       var result = System.Drawing.Color.FromName(inputColor);
       return result.IsKnownColor;
}

```
One regex for all, just for the fun. The i at the end is for case insensitivity. Probably not fast, but "one shot".

**HTML colors**

```
/^(#[a-f0-9]{6}|black|green|silver|gray|olive|white|yellow|maroon|navy|red|blue|purple|teal|fuchsia|aqua)$/i

```

**CSS colors**

```
/^(#[a-f0-9]{6}|#[a-f0-9]{3}|(rgb|hsl) *\( *[0-9]{1,3}%? *, *[0-9]{1,3}%? *, *[0-9]{1,3}%? *\)|(rgba|hsla) *\( *[0-9]{1,3}%? *, *[0-9]{1,3}%? *, *[0-9]{1,3}%? *, *[0-9]{1,3}%? *\)|black|green|silver|gray|olive|white|yellow|maroon|navy|red|blue|purple|teal|fuchsia|aqua)$/i

```