I got it working in first attempt!!!!!!
What I did was this:
we have 3 parts:
[img:hf]
.*
[/img:hf]
They should all 3 be removed. So we put (....) around it all.
- preg_replace removes the match, (....)
while
- preg_match keeps the match, (....)
Now, the following will work if there is only 1 such match in a string.
I do not know what will happen if there are several matches in a string ...
One little thing.
Result will be
'part a part b'
*notice: there are 2 spaces between part a and part b,
just as expected.
Could be converted to 1 space, using:
str_replace( ' ', ' ', $message);
my code is this:
<?php
$msg = 'part a [img:hf]http://mydom.net/images/redface.gif[/img:hf] part b';
$pattern = '#(\[img:hf\].*\[/img:hf\])#';
$message = preg_replace($pattern, '', $msg);
// test before and after
echo $msg;
echo '<br>';
echo $message;
regars 🙂
halojoy