Jerry Preston <[EMAIL PROTECTED]> asked: > I am trying to break down the following: > > printf("numsteps=%d i=%d im=%g vfr=%g > \n",numsteps,i,imeas,vforce); > into > "numsteps= numsteps i=i im=imeas vfr=vforce \n" > > printf ("\noriginal cap = %g, offset = %g", *ci, cap_offset); > into > "\noriginal cap = ci, offset = cap_offset"; > > I am wanting to improve my limited regex skills. Is the > above possible or > is there a better way with one method?
Off the top of my head: s/printf\s*\(\*(".*?").*?\);/$1;/g Anchoring the end of the pattern with ");" should insure you against mismatches when there is a function call instead of a variable in the argument list. Still, the pattern fails for weird templates like printf("some \"quoted\" text" ();", foo, baz, bar ); If you want to have a bullet-prrof solution, you should check out Text::Balanced, which takes care of stuff like balanced quotes, brackets and such. HTH, Thomas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]