> but the last "44444" would never get substituted. What would be the easiest > way to accomplish this? Change the RE from 'x([^x]*)x[^x]*x' to 'x([^x]*)x' Simply you do not seem to have another sequence after 44444 that is why it does nt work :)