)[\d\.-]+?(<\/Data><\/Cell>)#s'; $pre_replace="\\1\\2"; $template=preg_replace($pre_regex, $pre_replace, $template); // find all numbers like 99901, 99902 .... 99999 and replace them with {xnum_01}, {xnum_02} ... {xnum_99} // make sure that there is no adjacent digit before or after the number // NOTE: for this report, a special handling is applied // 99xxxx, ex: 990101, 990102, get the last for digits and add to xnum_ $pre_regex='#([^\d]+?)99(\d\d\d\d)([^\d]+?)#'; $pre_replace="\\1{xnum_\\2}\\3"; $template=preg_replace($pre_regex, $pre_replace, $template); // replace all xvar_1 etc with {xvar_1} $pre_regex='#(xv.*?_\d+)#'; $pre_replace="{\\1}"; $template=preg_replace($pre_regex, $pre_replace, $template); if ($additional_replaces) { $pre_regex=array( '#ss:ExpandedRowCount="\d+"#', '#.*?<\/Worksheet>#s', '#.*?<\/Worksheet>#s', '#.*?<\/Names>#s', '##s', '##s', '#<\/WorksheetOptions>#', ); $pre_replace=array( 'ss:ExpandedRowCount="74"', '', '', '', '', '', ' {PAGE_BREAK_ROW} ' ); $template=preg_replace($pre_regex, $pre_replace, $template); $pre_regex=array( '#({xnum_)(\d\d\d\d)#s', ); $pre_replace=array( "\\1{dtype_\\3}\\2\\3" ); $template=preg_replace($pre_regex, $pre_replace, $template); } return $template; } $filename = "C:/wamp/www/KAIHATSU/hegl/big report (keisu_ichiran) xml/keisu_ichiran_ForCompile.xml"; $handle = fopen($filename, "r"); $template = fread($handle, filesize($filename)); fclose($handle); $template1=preprocess_xml_template($template); echo $template1; ?>