in the first, i'm pretty sure that { is a special charater, so { and } should be \{ and \} respectively
in both of them, what i found was that the first entry was an empty string if there was nothing before the first delimiter.
here's the function i made to use for myself.. maybe we should send it to php.net for inclusion in version 5 to return an array of substrings...
Code: Select all
</php
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;
}
?>
i should note that i was looking at block of text with the tags [nocode][/nocode] in there and i wanted what was between them, to make it exempt from parsing, so i needed every other line. i think you need stage1... but a mod that should help would be....
Code: Select all
</php
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($i>0){
$stage2[]=$stage1[$i];
}
}
return $stage2;
}
?>
i called it like this:
$codeexempt=get_sub_pattern('|\[nocode](?U)(.*)\[/nocode]|i', $precode);
i didn't check, but did you include the i at the end?
without the i, you're looking for :
<entry>(U?)(.*)</entry>
with the i, you'll match <Entry>, <eNtry>, <enTry>, <entRy>, <ENTry> and any other variation you can think of. the i does case insensitivity... might actually help