Dynamically assign regex variables

My scenario is that in one repo i define two regex variables like so:

variables:
  DEV_GROUP: /^unit-(?:3d|8d)/
  MAIN_GROUP: /^unit-(?:3e|8e)/

In my other repo i include that file, and then, dynamically i set the GROUP variable to either DEV_GROUP or MAIN_GROUP. I have a job theat defines a variable UNIT, and the rule is setup that if UNIT matches GROUP then the job runs. But for the sake of simplicity, i will just assign GROUP to DEV_GROUP

variables:
  GROUP: $DEV_GROUP

manual_test_job:
  stage: all
  variables:
    UNIT: unit-3d
  script:
    - echo GROUP is "$GROUP"
  rules:
    - if: '$UNIT =~ $GROUP'
      when: always
    - when: manual

This does not work, the regex does not evaluate and the job does not run even though unit-3d matches the regex. When i run the job manually i can confirm that GROUP is equal to /^unit-(?:3d|8d)/. Now, if i replace the variables like so:

variables:
  GROUP: /^unit-(?:3d|8d)/

Now the regex gets evaluated correctly. I need to be able to dynamically assign GROUP to a regex variable to manage the jobs in my pipeline. It seems like if i assign GROUP to a variable that is a regex, GROUP gets treated as a string. How can i get this to work?

Edit:
I have also tried the following

variables:
  DEV_GROUP: ^unit-(?:3d|8d)
variables:
 GROUP: "/$DEV_GROUP/"