Set value of variable by expression or condition

How can I set the content of a pipeline variable by condition like:

variables:
  CI_IS_DEV_BRANCH: $CI_COMMIT_BRANCH == "dev"

In case of having several jobs like

build:
  stage: build
  rules:
    - if: '$CI_COMMIT_BRANCH == "dev"'

they could be simplified by

build:
  stage: build
  rules:
    - if: $CI_IS_DEV_BRANCH

If the dev branch name gets changed to “develop” only one line needs to be changed.
This is just a simple example to demonstrate my question.

Update:

Or even more like (to catch “dev” and “develop”):

variables:
  CI_IS_DEV_BRANCH: $CI_COMMIT_BRANCH =~ "/^dev.*"

Minor improvement, but does not really answer my question:

BTW:
Similar question with no helpful answer:

You can define a regex in variable and use that in rules. Choose when to run jobs | GitLab

What you want is currently not available as feature.