Skip to content

Replace Last ​

Replaces the last occurrence of a substring in a string.

liquid
{{ string | replace_last: substring, replacement }}

Example ​

liquid
{{ 'red-blue-red' | replace_last: 'red', 'green' }}

Output

html
red-blue-green