in reply to Making multiple replaces through Regex
code is, first check whether format given is right, if it is then use some temporary variables, and do the string concatenation with the help of it.if(/<csp c="(\d+)">/) { $number= 1; $iteration = $1; $string .= '<colspec colnum="'. $number . '" colname="col' . $number+ ++ . '"/>' while ( $iteration-- ); } print $string;
|
|---|