Question: I'm sorry, I'm sure this will get marked as duplicate but I can not get my regex to work properly.

I want my regex to only allow lowercase letters, periods, and underscores. I'm using the instagram regex from the community patterns found here <https://regexr.com/3cg7r>

The pattern looks like `^(?!.*\.\.)(?!.*\.$)[^\W][\w.]{0,29}$`

Figured I could add `[a-z]` at the beginning of the pattern right after the carrot "^" but that didn't do anything. I tried various other ways like `[^A-Z]` which I thought would work but didn't.

Can someone steer me in the right direction?

Edit:

I want to match:

`test_handle`

`test.handle`

`testhandle`

`test_._handle`

Don't want to match:

`Test_handle`

`test_Handle`

`test__handle`

`test..handle`

`TESTHANDLE`

an

Answer: 
Try this regex:

```
^(?!.*\.\.)(?!.*__)(?!.*[A-Z])(?!.*\.$)[^\W][\w.]{0,29}$

```

[RegExr demo](https://regexr.com/453us)

I've added this negative lookahead to disallow uppercase characters:

```
(?!.*[A-Z])

```

And this one to disallow double underscores:

```
(?!.*__)

```

---

One other important thing to remember is to uncheck the case insensitive flag.

[![enter image description here](https://i.stack.imgur.com/imOfP.png)](https://i.stack.imgur.com/imOfP.png)
I found your issue:

The flags you have selected `igm` include the `case insensitive` flag. 

To make your regex exclude uppercase letters, disable that and try again with `^[a-z]...`

This should sort it out for you, but do comment if you can't get it to work, I'll try to help.