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: 
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.
You could try something like 

`^(?:[a-z]|([._])(?!\1))+$`

Explained 

```
 ^                             # BOS
 (?:                           # Repeat many times
      [a-z]                         # a - z
   |                              # or,
      ( [._] )                      # (1), dot or underscore
      (?! \1 )                      # not followed by same
 )+
 $                             # EOS

```