As a workaround you could use the string slice
method
- with as
startIndex: some_string length - sub_string length
and
stringLength: sub_string size
- and if the result of the slice is the same as the sub_string -> the sub_string is at the end of some_string.
it's a bit clumpy in a liquid template but it would look like:
{% capture sub_string %}{{'subString'}}{% endcapture %}
{% capture some_string %}{{'some string with subString'}}{% endcapture %}
{% assign sub_string_size = sub_string | size %}
{% assign some_string_size = some_string | size %}
{% assign start_index = some_string_size | minus: sub_string_size %}
{% assign result = some_string | slice: start_index, sub_string_size %}
{% if result == sub_string %}
Found string at the end
{% else %}
Not found
{% endif %}
and if the some_string is empty or shorter than sub_string it works anyway because the slice result would be empty as well
capture
instead ofassign
? – Bloodshot