0

i have a multi-language site setup with low search. every language has it's own collection - this works quite nice. Now i might have been a bit too excited about template partials and let the client fill in a lot of content in which he can insert all sorts of images and other stuff by doing for example "{image_12}"... this tags are now in my search-excerpts as well and i want them gone.

i try to filter them out with low replace but it finds only the first occurrences of my query. my code looks something like this:

<ul>
{exp:low_search:results query="{segment_3}" status="not closed" limit="10" disable="member_data"}
        <li>
            <h3><a href="/{language_code}{page_uri}">{bbr-mls:title}</a></h3>
            {exp:low_replace find="\{.*?\}" replace="" regex="yes"}{low_search_excerpt}{/exp:low_replace}
        </li>
{/exp:low_search:results}    
</ul>

any help much appreciate (and sorry low for bugging you on twitter - you are right, this is the place to ask.)

cheers, moritz

2

Your example actually worked fine in a test I did. But it could be that the curly brackets are encoded to entities, so the regex doesn't actually match. You could try this:

{exp:low_replace find="(\{|&#123;)[\w\-]+?(\}|&#125;)" regex="yes"}
    {low_search_excerpt}
{/exp:low_replace}

If you're just filtering out those image tags, you could also consider wrapping the Low Replace tag around the whole Low Search Results tag:

{exp:low_replace find="(\{|&#123;)image_\d+(\}|&#125;)" regex="yes"}
    {exp:low_search:results ... }
        ...
    {/exp:low_search:results}
{/exp:low_replace}
  • the better regex worked right away. thank you! – portnull Oct 28 '13 at 7:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.