Re: [kaza_perl] How to match a function of back reference?
[In reply to]

Can't Post

I would not expect a single regular expression to be able to do this. They only deal with characters. Numbers are just character strings, they have no numeric value. Your task is straightforward in perl. Just use two regular expressions.

Note: In your examples, you always find the larger number. Even a second regex would fail to find a match to a larger one. Good Luck, Bill

Re: [Laurent_R] How to match a function of back reference?
[In reply to]

Can't Post

Thanks for everyone who replied!

The whole /match/ regex is a part of already written script so it places a limitation of single-line regex. I hoped that there is some (strange?) syntax allowing matching a function of a back reference, in a similar way to a replacement by a function of a match, like:

@{[${1}-1]}

but as I see from the replies, there isn't such a thing. OK, either I'll have to use groups of 4 or 8 regex arguments (for indices [1-4]->[0-3], [1-8]->[0-7], they're not diverse) instead of a single regex argument I hoped to come with or I'll have to declare in the script a hardcoded associative array