diff --git a/_filters/remove_last.md b/_filters/remove_last.md new file mode 100644 index 00000000..fbc26473 --- /dev/null +++ b/_filters/remove_last.md @@ -0,0 +1,19 @@ +--- +title: remove_last +description: Liquid filter that removes the last occurence of a given substring from a string. +version-badge: 5.2.0 +--- + +Removes only the last occurrence of the specified substring from a string. + +
Input
+```liquid +{%- raw -%} +{{ "I strained to see the train through the rain" | remove_last: "rain" }} +{% endraw %} +``` + +Output
+```text +I strained to see the train through the +``` diff --git a/_filters/replace_last.md b/_filters/replace_last.md new file mode 100644 index 00000000..1a01cfc6 --- /dev/null +++ b/_filters/replace_last.md @@ -0,0 +1,19 @@ +--- +title: replace_last +description: Liquid filter that replaces the last occurrence of a given substring in a string. +version-badge: 5.2.0 +--- + +Replaces only the last occurrence of the first argument in a string with the second argument. + +Input
+```liquid +{%- raw -%} +{{ "Take my protein pills and put my helmet on" | replace_last: "my", "your" }} +{% endraw %} +``` + +Output
+```text +Take my protein pills and put your helmet on +```