regexnintex-workflow

Looking for regex to match before and after a number


Given the string

170905-CBM-238.pdf

I'm trying to match 170905-CBM and .pdf so that I can replace/remove them and be left with 238.

I've searched and found pieces that work but can't put it all together.
This-> (.*-) will match the first section and
This-> (.[^/.]+$) will match the last section

But I can't figure out how to tie them together so that it matches everything before, including the second dash and everything after, including the period (or the extension) but does not match the numbers between.

help :) and thank you for your kind consideration.


Solution

  • There are several options to achieve what you need in Nintex.

    If you use Extract operation, use (?<=^.*-)\d+(?=\.[^.]*$) as Pattern.

    See the regex demo.

    Details

    If you use Replace text operation, use

    Pattern: ^.*-([0-9]+)\.[^.]+$
    Replacement text: $1

    See another regex demo (the Context tab shows the result of the replacement).

    Details

    The replacement $1 references the value stored in Group 1.