Low Search and the new Regular Expression conditionals
Hi Low,
After i've did a update to EE2.9, errors appears with Low Search using:
{category_id}"{if category_id IN ({low_search_category:type})}{/if}
I read the docs of Low Search and it's written that he best way to approach is:
{if pipe_separated_items ~ '/(^|\|)'.single_item.'($|\|)/'} ... {/if}
But I didn't understand about the syntax.
I have to modify the code like this:
{if low_search_category ~ '/(^|\|)'.category_id.'($|\|)/'} {/if}
it is correct?
Where could I read documentation about this kind of syntax for EE2.9, it sounds weird compared to:
{category_id}"{if category_id IN ({low_search_category:type})}{/if}
Regards,
Stéphane
Replies
Low 22 Aug 2014 08:51
Yes, the syntax is correct, and I concur: it doesn't sound as nice as the IN conditionals.
Your last example would be this:
Which reads something like: if the pipe-separated list matches a single item in that list. The regular expression syntax looks for a single category ID with either the beginning of the string on the left or a pipe, and the end of the string or a pipe on the right.
There are multiple ways of using the regex conditional, but this is the way I recommend you use it for now.
Here are the (limited) docs on the Matches operator: https://ellislab.com/expressionengine...
Stéphane Cabaret 22 Aug 2014 14:06
Hi Low,
Thanks for your fast and efficient support. It's true the docs on Matches operator are limited.
have a good week-end!