Jerry Preston wrote: > > I am trying to change some text from: > > if ( (fabs(log(im[ii]/im[ii-1])/vstep) > > fabs(3*log(im[ii-1]/im[ii-5])/(4*vstep)) ) && ((im[ii] > ifr[x]) || > (im[ii-1] > ifr[x])) ) { > to > if ( (fabs(log(im[ii]/im[ii-1])/vstep) > fabs(3 * > log(im[ii-1]/im[ii-5])/(4 * vstep)) ) && ((im[ii] > ifr[x]) || (im[ii-1] > > ifr[x])) ) { > ^^^ > ^^^ > with the following: > > s/(?=[A-z|0-9]+)\*(?=[A-z]+)/' * '/g; > > What am I doing wrong?
Hi Jerry. Hmm. I had to pull that apart before I realised that what you're trying to do is put spaces around all multiplication operators! What you're doing wrong is using two look-aheads instead of one look-behind and one look-ahead. You're also trying too hard! s/(\w)\*(\w)/$1 * $2/g will do it, as in the code below. HTH, Rob use strict; use warnings; my $c_code = ' fabs(3*log(im[ii-1]/im[ii-5])/(4*vstep)) '; print $c_code, "\n"; $c_code =~ s/(\w)\*(\w)/$1 * $2/g; print $c_code, "\n"; **OUTPUT** fabs(3*log(im[ii-1]/im[ii-5])/(4*vstep)) fabs(3 * log(im[ii-1]/im[ii-5])/(4 * vstep)) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]