preg_replace/eregi_replace issue
Posted: Mon Jun 30, 2003 1:11 pm
i'm not sure if the issue is in the function i made or in the eregi. i know the function i made returns every other one and the first one, if it starts with a [nocode][/nocode] block is an empty string. i built that up in a different file to make sure i had the function working right (only it wasn't a function there, so i might be returning wrong)
for those interested in playing with the code as it is and seeing the full code, here's the full code (minus the opening <?php): http://people.brandeis.edu/~m3rajk/JMT/ ... 2.disp.txt and the code in action: http://people.brandeis.edu/~m3rajk/JMT/ ... a-fcv2.php
the test string i have been using: [nocode]what will happen with this block?[/nocode] and then this should be bold [nocode][c]and this should not be centered[/c][/nocode] and i can't think of more
here's the function and the added replacement:
for those interested in playing with the code as it is and seeing the full code, here's the full code (minus the opening <?php): http://people.brandeis.edu/~m3rajk/JMT/ ... 2.disp.txt and the code in action: http://people.brandeis.edu/~m3rajk/JMT/ ... a-fcv2.php
the test string i have been using: [nocode]what will happen with this block?[/nocode] and then this should be bold [nocode][c]and this should not be centered[/c][/nocode] and i can't think of more
here's the function and the added replacement:
Code: Select all
function get_sub_pattern($pattern, $inputstring){
$stage1=preg_split($pattern, $inputstring, -1, PREG_SPLIT_DELIM_CAPTURE);
$stage2=array();
$blocks=count($stage1);
for($i=0;$i<$blocks;$i++){
if(!(is_long($i/2))){
$stage2[]=$stage1[$i];
}
}
return $stage2;
}
# make replacements
# code exempt section (remove)
$codeexempt=get_sub_pattern('|\[nocode]([^]]*)\[/nocode]|i', $precode);
$postcode=eregi_replace('\[nocode][^]]*\[/nocode]', '&&&', $precode);