The easiest solution might be to create a separate function (say, formatString ) that is the callback for the editbox and the pushbutton (which I am guessing is how the user can browse to the desired directory.)
The formatString function will serve the sole purpose of doing the regexp to format the string, and set the output to the editbox string.
Doug Hull (or Stuart now) had a good example here on this kind of operation. It might be worth the few minutes to watch? You can find the video here .
Again, the message is set up one function that can be called upon from different locations (in this case the original pushbutton and then the editbox .) This way, it might be easier to scale up later on.
A bit of a long-winded answer, but HTH.