Finding patterns in pandas

I would need to find the common users which have

  • a pattern AA in CODE;
  • a pattern __ in CODE;
  • numbers in CODE;

The dataset looks like:

User_ID       CODE

A12          AAada __fa
F453         21 ads
J43          Has AA 
...          ...
H21          MNasdf
L32          sad 21
M54          43__12 asd
...          ...

What I should do is:

  1. find first all the user IDs which have AA in CODE, i.e. A12 and J43;
  2. find all the users which have __ in CODE, i.e. A12 and M54;
  3. find all the users which have numbers in CODE, i.e. F453, L32 and M54.

Then I should consider the intersection between 1) and 2), 1) and 3), 2) and 3) I order to have:

  1. A12;
  2. no elements in common;
  3. M54.

I shared with you all the exercise, but I actually difficulties in determining the user IDS for the patterns. Probably I should use regex to match a specific pattern in strings in CODE, something like ^[^0-9]*$ in case of numbers or /[$-/:-?{-~!"^_[]]/in case of__` (I might be also interested in other symbols so also considering all of them would be fine).

Could you please help me in finding the above values, explaining how to correctly use regex? Of course, if there is another good way to approach the exercise, I would be interested in it too.