Hi everyone,
I try to replace one specific part As Constant( t Quantile( 1 - 0.1 / 2,
in every selected column formula by Random t((
.
However, I fail in the regex part. I think it could have to do with escaping the brackets. I tried with \!\ but also failed here...
Could someone debug my code below?
// Select some columns
dt = currentdatatable();
dt << Get Selected Columns;
//'fix' each selected column formula by manipulating the formula as a string
for each( {col, c}, dt << Get Column References( dt << Get Selected Columns ),
newf = regex(
char(col << Get Formula),
"As Constant( t Quantile( 1 - 0.1 / 2, ",
"Random t((",
GLOBALREPLACE
);
//show(Parse(newf));
Eval( Eval Expr(
col << Set Formula( Expr( Parse(newf) ) )
) );
);