Padding numbers in sort fields

Hi

Is there a way to pad the first number that appears (anywhere) in a field?

e.g. "Symphony No. 1 in E minor" > "Symphony No. 001 in E minor"

I know how to find the number using regex, but I can't work out a way of padding it (say to three digits) if I don't know how many digits it was in the first place. This problem appears to be a mix of regex (to find the number) and formatting $num(x,y) to pad it.

Any ideas?

Thanks

I Think if you separate the search into several bits it might be less horrifying:

A search string like "Symphony No. 001 in E minor" can be divided into 3 sections:
the string in front of the number, ths number and the string behind the number.

Searching for such a thing would be:
(.* )(\d+)( .*)
separates the search into
(%1)(%2)(%3) where you can read the % as "part".

replacing it would look something like this:
%1$num(%2,y)%3

This is the basic idea. try it first whether it works

Placeholders for groups in regular expressions are denoted using the dollar sign (e.g., $1 for the first group, $2 for the second group, and so on).

You can try an action Replace with regular expression
Field: YOURSORTFIELD
Regular expression: (.)(\d+)(.)
Replace matches with: $1$num($2,3)$3