Working with strings using Liquid can be a very powerful tool within Looker, but it also can add another complexity layer when you use it, as this is an external template language created by Shopify.
One of the weird cases I came across was when I had to extract values from a string list similar to this, without using SQL:
['cat', 'dog', 'bird', 'insect']
To create an HTML list as described here: Using Liquid Split and Array Filters to Format Lists
Like this:
The problem was that using the single quote as is, or escaped, was not removing the single quotes '
around the strings.
Test 1:
html:
{% assign animals = value | remove: "'" | remove: "[" | remove: "]" | split: ", " %}
<ul>
{% for animal in animals %}
<li>{{ animal }}</li>
{% endfor %} ;;
Test 2:
html:
{% assign animals = value | remove: "\'" | remove: "[" | remove: "]" | split: ", " %}
<ul>
{% for animal in animals %}
<li>{{ animal }}</li>
{% endfor %} ;;
Result (for both tests):
In order for this to work, the HTML Code for the single quote “'” can be used, like this:
html:
{% assign animals = value | remove: "'" | remove: "[" | remove: "]" | split: ", " %}
<ul>
{% for animal in animals %}
<li>{{ animal }}</li>
{% endfor %} ;;
Result: