in reply to Help with regex - find captured pattern twice
A bit broader than you specified - this replaces any single letter and optional parenthetical value.
$_= "c*theta*h^(1+psi)=(1-alpha)*y;\n1 = beta*(c/c(+1)*alpha*y(+1)/k+( +1-delta));\ny = a*(k(-1)^alpha)*(h^(1-alpha));\nk = y-c+(1-delta)*k(- +1);\nln(a) = rho*ln(a(-1))+ e;\n"; s/(?<!\pL)(\pL)(\([\d+-]+\))?(?!\pL)/(${1}SS*exp($1$2))/g; print; #prints (cSS*exp(c))*theta*(hSS*exp(h))^(1+psi)=(1-alpha)*(ySS*exp(y)); 1 = beta*((cSS*exp(c))/(cSS*exp(c(+1)))*alpha*(ySS*exp(y(+1)))/(kSS*ex +p(k))+(1-delta)); (ySS*exp(y)) = (aSS*exp(a))*((kSS*exp(k(-1)))^alpha)*((hSS*exp(h))^(1- +alpha)); (kSS*exp(k)) = (ySS*exp(y))-(cSS*exp(c))+(1-delta)*(kSS*exp(k(-1))); ln((aSS*exp(a))) = rho*ln((aSS*exp(a(-1))))+ (eSS*exp(e));
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Help with regex - find captured pattern twice
by pachydermic (Beadle) on Apr 11, 2013 at 13:52 UTC | |
by hbm (Hermit) on Apr 12, 2013 at 03:11 UTC |