In a character class can I match full words?
Using this code, the regular expression removes the {else}
tag, so is it possible to add else
inside of the character class as a word, and not as 4 letters?
$section = "
{if {money} == 'yes'}
Sweet!
{else}
Too bad...
{/if}
";
echo preg_replace("/\{[^ \/]+\}/iU", "''", $section);
I thought that this might work (but it doesn't):
echo preg_replace("/\{[^ (else)\/]+\}/iU", "''", $section);
Expected output:
{if '' == 'yes'}
Sweet!
{else}
Too bad...
{/if}