Remove text from tag, keep numbers

Hi, I am pretty new at this and can not figure out how to remove all text before the numbers. I have a tag called OPUS, which contains text and a number.
I would like to have

  1. a OPUSSORT tag which only contains numbers.
    For example;
    opus = T. 65
    opussort would be 65
    opus = BWV 1003a
    opussort would be 1003

  2. a OPUSNUMBER tag which contains the numbers and the text thereafter.
    For example;
    opus = T. 65
    opusnumber would be 65
    opus = BWV 1003a
    opusnumber would be 1003a

Hope someone can help me with writing the action codes for these 2,
Thanks

Try an action of the type "Format value" for OPUSSORT with
Format string: $regexp(%opus%,.*?(\d+.*),$1)

Try an action of the type "Format value" for OPUSNUMBER with
Format string: $num($regexp(%opus%,.*?(\d+.*),$1),1)

1 Like