Question: I do not understand the behavior. I have such example, need to catch html comment.

```
var str = '.. <!--My -- comment test--> ';

var regex1 = /<!--[.]*-->/g;
var regex2 = /<!--.*-->/g;

alert(str.match(regex1));      // null
alert(str.match(regex2));      // <!--My -- comment test--> 

```

The second regex `regex2` works fine, outputs exactly what's needed. The first shows `null`. And I don't understand the difference. RegExpressions `<!--[.]*-->` and `<!--.*-->` mean the same - "after `<!--` take ANY character except newline in quantity from 0 to as many as possible and finish with `-->`". But for the second it works and for the first does not. Why?

UPD.
I've read comments and have an update.

```
var str3 = '.. <!--Mycommenttest--> ';
var str4 = '.. <!--My comment test--> ';

var regex3 = /<!--[\w]*-->/g;
var regex4 = /<!--[\s\S]*-->/g;

alert(str.match(regex3));         // <!--Mycommentstest-->
alert(str.match(regex4));         // <!-- My comment test -->

```

So it's possible to use limited matching variables to match anything. So which way should be used to use RegExps right way? With `[]` or without them? Can't get the difference, both give the right output.

Answer: 
The dot (`.`) does not mean "anything" inside a character class. Why would you need a character class to match anything?
> 
> RegExpressions `<!--[.]*-->` and `<!--.*-->` mean the same
> 
> 
> 

This is not correct. 

The brackets `[]` indicate a character class, where any character in the class may be matched. `[.]` is the character class which contains the '`.`' character. Contrast this with `.`, which is a **pre-defined** character class taken to mean "any character" (except for line-terminators).

So what you're matching with `<!--[.]*-->` is either an empty comment or a comment consisting wholly of '`.`' characters. And what you're matching with `<!--.*-->` is either an empty comment or a comment filled with any character except linebreaks.