Run multibranch pipeline on PRs only when target pipeline starts from release/*

Hi, powerfull Jenkins Community! We have a bunch of PR checks and want to run them on PRs that opened only to develop master branches and branches with names started from release/*, for example release/2.1 release/2.3 etc. I have this construction in pipelines:

when {
                anyOf {
                    changeRequest target: 'master'
                    changeRequest target: 'develop'
                    changeRequest target: 'release/*'
                }
                beforeOptions true
                beforeInput true
                beforeAgent true
            }

But it seems changeRequest target: 'release/* is not working, for some reason, but previous two options works well. Pipeline skips all PRs that destination not master or develop and ignore PRs with destination release/2.1. How I can deal with it?

According to the doc of the feature, you should add a comparator to use a regexp:

The optional parameter comparator may be added after an attribute to specify how any patterns are evaluated for a match: EQUALS for a simple string comparison (the default), GLOB for an ANT style path glob (same as for example changeset), or REGEXP for regular expression matching. Example: when { changeRequest authorEmail: "[\\w_-.]+@example.com", comparator: 'REGEXP' }

from Pipeline syntaxt

It works now, thank you

when {
                anyOf {
                    changeRequest target: 'master'
                    changeRequest target: 'develop'
                    changeRequest target: 'release\\/.*', comparator: 'REGEXP'
                }
                beforeOptions true
                beforeInput true
                beforeAgent true
}