Here is my code in a snippet. Basically what low_replace does is just to convert spaces to dashes.
{exp:low_replace find="SPACE" replace="-"}
{permalink="product"}/
{field_a}-
{related_entries id="foo"}
{foo_name}
{/related_entries}
-{field_b}
{if bar != ''}-{bar}{/if}
{related_entries id="test"}-
{test_name}
{/related_entries}/
{/exp:low_replace}
When I tried it, I got this error
Parse error: syntax error, unexpected T_STRING in /home/test/public_html/system/expressionengine/libraries/Functions.php(683) : eval()'d code on line 1
Any idea why this is the case?