Question: Evening,

I want to search some columns in a MySQL table for any instances of [a-z]\.[a-z], for example:

John.than, Ame.ica, Llan.antffraid etc.

but I don't want this to include the strings 'a.m.' OR 'p.m.'. I have tried using (?!a.m.|p.m.) but this does not work. It returns the error: "Got error 'repetition-operator operand invalid' from regexp".

I have the following regular expression:

```
REGEXP BINARY '[a-z]\\\.[a-z]'

```

N.B. If a colum includes a.m. OR p.m. but also contains a string like bro.ken, it needs to be returned.

Answer: 
If you can use assertions, this might work, but not sure about backtracking.

```
 #  (?=^.*(?:(?!a\.m|p\.m)[a-z]\.[a-z]|(?:a\.m|p\.m).*(?!a\.m|p\.m)[a-z]\.[a-z]))

 (?=
      ^
      .* 
      (?:
           (?! a\.m | p\.m )
           [a-z] \. [a-z] 
        |  
           (?: a\.m | p\.m )
           .* 
           (?! a\.m | p\.m )
           [a-z] \. [a-z]
      )
 )

```
I would do it like this:

```
SELECT 'Ame.ica wakes up at 8 a.m.' REGEXP
   '[b-oq-z]\\.[a-ln-z]|[ap]\\.[^m]|[^ap]\\.m|[[:alpha:]][ap]\\.m|[ap]\\.m[[:alpha:]]' findme,
  'America wakes up at 8 a.m.' REGEXP
   '[b-oq-z]\\.[a-ln-z]|[ap]\\.[^m]|[^ap]\\.m|[[:alpha:]][ap]\\.m|[ap]\\.m[[:alpha:]]' dontfindme

```

It's a shorter and therefor slightly faster version of dognose's answer. Also it's tailored to MySQL which has the slightly odd `[[:alpha:]]` class.