I have a script that takes a string input from users. I am looking to check that the string input should have exactly 2 dots. The relevance is only to the dots. The string should not start and end with a dot.There should be no consecutive dots.

This is the pattern I am using:

```
^[^\.]*\.[^\.]*\.[^\.]*$

```

**This is the string I am looking for**:

```
abc.def.xyz

```

But in the pattern above, if dots are in front or at the end, then that string gets selected - which I don't want. There should be only two dots in the string.

**Not wanted:**

```
.abc.xyz # no dot at the start   
abc.xyz. # no dot at the end   
abc.def.ced.xyz # only two dots not more than that

```

I have tried using `(?!\.)` for the dot at the start, but it didn't work.