Run pipeline only for staging branch and for other branches run based on the variables provided

Hello every,

I want to run pipeline always for a specific branch and for other branches pipeline should only run if the commit message contains a specific string in it.

Example:
stages:
  - running_test

tests_execution:
  stage: running_test
  image: image:X.X.X

  script:
    - echo $CI_COMMIT_MESSAGE

  only:
    refs:
      - testing
  except:
    variables:
      - $CI_COMMIT_MESSAGE =~ /pipeline/

Explanation

In the above example I am trying to execute pipeline for testing branch always and for other branches If the commit message contains /pipeline/ in it only then pipeline will be executed.

It is not working correctly, can anyone tell me what I am doing wrong?

Thank you